Skip to content

Commit f1a8f63

Browse files
authored
Further fixes for whitespace (#10210)
1 parent c96db29 commit f1a8f63

File tree

1 file changed

+22
-15
lines changed
  • src/datascience-ui/history-react/redux/reducers

1 file changed

+22
-15
lines changed

src/datascience-ui/history-react/redux/reducers/creation.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,29 @@ export namespace Creation {
5353

5454
// No elseif as we want newly visible cells to pick up the correct expand / collapse state
5555
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;
6974
}
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;
7279
newCellVM.inputBlockText = newText;
7380
}
7481
}

0 commit comments

Comments
 (0)