Skip to content

Commit be772e1

Browse files
committed
Revert "Implement scroll by last line"
This reverts commit 584821e.
1 parent 584821e commit be772e1

File tree

4 files changed

+3
-91
lines changed

4 files changed

+3
-91
lines changed

news/2 Fixes/9116.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/datascience-ui/common/index.ts

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -54,37 +54,6 @@ export function splitMultilineString(source: nbformat.MultilineString): string[]
5454
return [];
5555
}
5656

57-
export function removeLinesFromFrontAndBack(code: string): string {
58-
const lines = code.splitLines({ trim: false, removeEmptyEntries: false });
59-
let foundNonEmptyLine = false;
60-
let lastNonEmptyLine = -1;
61-
let result: string[] = [];
62-
parseForComments(
63-
lines,
64-
(_s, i) => {
65-
result.push(lines[i]);
66-
lastNonEmptyLine = i;
67-
},
68-
(s, i) => {
69-
const trimmed = s.trim();
70-
if (foundNonEmptyLine || trimmed) {
71-
result.push(lines[i]);
72-
foundNonEmptyLine = true;
73-
}
74-
if (trimmed) {
75-
lastNonEmptyLine = i;
76-
}
77-
}
78-
);
79-
80-
// Remove empty lines off the bottom too
81-
if (lastNonEmptyLine < lines.length - 1) {
82-
result = result.slice(0, result.length - (lines.length - 1 - lastNonEmptyLine));
83-
}
84-
85-
return result.join('\n');
86-
}
87-
8857
// Strip out comment lines from code
8958
export function stripComments(str: string): string {
9059
let result: string = '';

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

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import { Identifiers } from '../../../../client/datascience/constants';
55
import { InteractiveWindowMessages } from '../../../../client/datascience/interactive-common/interactiveWindowTypes';
66
import { ICell, IDataScienceExtraSettings } from '../../../../client/datascience/types';
7-
import { removeLinesFromFrontAndBack } from '../../../common';
87
import { createCellVM, extractInputText, ICellViewModel, IMainState } from '../../../interactive-common/mainState';
98
import { createPostableAction } from '../../../interactive-common/redux/postOffice';
109
import { Helpers } from '../../../interactive-common/redux/reducers/helpers';
@@ -20,14 +19,6 @@ export namespace Creation {
2019
return true;
2120
}
2221

23-
function extractInputBlockText(cellVM: ICellViewModel, settings?: IDataScienceExtraSettings) {
24-
// Use the base function first
25-
const text = extractInputText(cellVM, settings);
26-
27-
// Then remove text on the front and back. We only do this for the interactive window
28-
return removeLinesFromFrontAndBack(text);
29-
}
30-
3122
export function alterCellVM(cellVM: ICellViewModel, settings?: IDataScienceExtraSettings, visible?: boolean, expanded?: boolean): ICellViewModel {
3223
if (cellVM.cell.data.cell_type === 'code') {
3324
// If we are already in the correct state, return back our initial cell vm
@@ -50,13 +41,13 @@ export namespace Creation {
5041
if (cellVM.inputBlockOpen !== expanded && cellVM.inputBlockCollapseNeeded && cellVM.inputBlockShow) {
5142
if (expanded) {
5243
// Expand the cell
53-
const newText = extractInputBlockText(cellVM, settings);
44+
const newText = extractInputText(cellVM, settings);
5445

5546
newCellVM.inputBlockOpen = true;
5647
newCellVM.inputBlockText = newText;
5748
} else {
5849
// Collapse the cell
59-
let newText = extractInputBlockText(cellVM, settings);
50+
let newText = extractInputText(cellVM, settings);
6051
if (newText.length > 0) {
6152
newText = newText.split('\n', 1)[0];
6253
newText = newText.slice(0, 255); // Slice to limit length, slicing past length is fine

src/test/datascience/cellFactory.unit.test.ts

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
'use strict';
44
import { assert } from 'chai';
55
import { generateCells } from '../../client/datascience/cellFactory';
6-
import { removeLinesFromFrontAndBack, stripComments } from '../../datascience-ui/common';
6+
import { stripComments } from '../../datascience-ui/common';
77

88
// tslint:disable: max-func-body-length
99
suite('Data Science CellFactory', () => {
@@ -150,51 +150,4 @@ class Pizza(object):
150150
nonComments = stripComments(multilineQuoteInFunc);
151151
assert.equal(nonComments.splitLines().length, 6, 'Splitting quote in func wrong number of lines');
152152
});
153-
154-
test('Line removal', () => {
155-
const entry1 = `# %% CELL
156-
157-
first line`;
158-
const expected1 = `# %% CELL
159-
first line`;
160-
const entry2 = `# %% CELL
161-
162-
first line
163-
164-
`;
165-
const expected2 = `# %% CELL
166-
first line`;
167-
const entry3 = `# %% CELL
168-
169-
first line
170-
171-
second line
172-
173-
`;
174-
const expected3 = `# %% CELL
175-
first line
176-
177-
second line`;
178-
179-
const entry4 = `
180-
181-
if (foo):
182-
print('stuff')
183-
184-
print('some more')
185-
186-
`;
187-
const expected4 = `if (foo):
188-
print('stuff')
189-
190-
print('some more')`;
191-
let removed = removeLinesFromFrontAndBack(entry1);
192-
assert.equal(removed, expected1);
193-
removed = removeLinesFromFrontAndBack(entry2);
194-
assert.equal(removed, expected2);
195-
removed = removeLinesFromFrontAndBack(entry3);
196-
assert.equal(removed, expected3);
197-
removed = removeLinesFromFrontAndBack(entry4);
198-
assert.equal(removed, expected4);
199-
});
200153
});

0 commit comments

Comments
 (0)