@@ -53,22 +53,29 @@ export namespace Creation {
53
53
54
54
// No elseif as we want newly visible cells to pick up the correct expand / collapse state
55
55
if ( cellVM . inputBlockOpen !== expanded && cellVM . inputBlockCollapseNeeded && cellVM . inputBlockShow ) {
56
- if ( expanded ) {
57
- // Expand the cell
58
- const newText = extractInputBlockText ( cellVM , settings ) ;
59
-
60
- newCellVM . inputBlockOpen = true ;
61
- newCellVM . inputBlockText = newText ;
62
- } else {
63
- // Collapse the cell
64
- let newText = extractInputBlockText ( cellVM , settings ) ;
65
- if ( newText . length > 0 ) {
66
- newText = newText . split ( '\n' , 1 ) [ 0 ] ;
67
- newText = newText . slice ( 0 , 255 ) ; // Slice to limit length, slicing past length is fine
68
- newText = newText . concat ( '...' ) ;
56
+ let newText = extractInputBlockText ( cellVM , settings ) ;
57
+
58
+ // While extracting the text, we might eliminate all extra lines
59
+ if ( newText . includes ( '\n' ) ) {
60
+ if ( expanded ) {
61
+ // Expand the cell
62
+ newCellVM . inputBlockOpen = true ;
63
+ newCellVM . inputBlockText = newText ;
64
+ } else {
65
+ // Collapse the cell
66
+ if ( newText . length > 0 ) {
67
+ newText = newText . split ( '\n' , 1 ) [ 0 ] ;
68
+ newText = newText . slice ( 0 , 255 ) ; // Slice to limit length, slicing past length is fine
69
+ newText = newText . concat ( '...' ) ;
70
+ }
71
+
72
+ newCellVM . inputBlockOpen = false ;
73
+ newCellVM . inputBlockText = newText ;
69
74
}
70
-
71
- newCellVM . inputBlockOpen = false ;
75
+ } else {
76
+ // If all lines eliminated, get rid of the collapse bar.
77
+ newCellVM . inputBlockCollapseNeeded = false ;
78
+ newCellVM . inputBlockOpen = true ;
72
79
newCellVM . inputBlockText = newText ;
73
80
}
74
81
}
0 commit comments