mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-20 19:14:10 +01:00
fix #141687.
This commit is contained in:
@@ -260,7 +260,7 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> implements ID
|
||||
const bottomModelIndex = this._viewModel!.getCellIndex(bottomElement);
|
||||
|
||||
if (bottomModelIndex - topModelIndex === bottomViewIndex - topViewIndex) {
|
||||
this.visibleRanges = [{ start: topModelIndex, end: bottomModelIndex }];
|
||||
this.visibleRanges = [{ start: topModelIndex, end: bottomModelIndex + 1 }];
|
||||
} else {
|
||||
this.visibleRanges = this._getVisibleRangesFromIndex(topViewIndex, topModelIndex, bottomViewIndex, bottomModelIndex);
|
||||
}
|
||||
@@ -568,9 +568,9 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> implements ID
|
||||
// no hidden area after it
|
||||
if (stack.length) {
|
||||
if (stack[stack.length - 1] === modelIndex - 1) {
|
||||
ranges.push({ start: stack[stack.length - 1], end: modelIndex });
|
||||
ranges.push({ start: stack[stack.length - 1], end: modelIndex + 1 });
|
||||
} else {
|
||||
ranges.push({ start: stack[stack.length - 1], end: stack[stack.length - 1] });
|
||||
ranges.push({ start: stack[stack.length - 1], end: stack[stack.length - 1] + 1 });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -581,9 +581,9 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> implements ID
|
||||
// there are hidden ranges after it
|
||||
if (stack.length) {
|
||||
if (stack[stack.length - 1] === modelIndex - 1) {
|
||||
ranges.push({ start: stack[stack.length - 1], end: modelIndex });
|
||||
ranges.push({ start: stack[stack.length - 1], end: modelIndex + 1 });
|
||||
} else {
|
||||
ranges.push({ start: stack[stack.length - 1], end: stack[stack.length - 1] });
|
||||
ranges.push({ start: stack[stack.length - 1], end: stack[stack.length - 1] + 1 });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -594,7 +594,7 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> implements ID
|
||||
}
|
||||
|
||||
if (stack.length) {
|
||||
ranges.push({ start: stack[stack.length - 1], end: stack[stack.length - 1] });
|
||||
ranges.push({ start: stack[stack.length - 1], end: stack[stack.length - 1] + 1 });
|
||||
}
|
||||
|
||||
return reduceCellRanges(ranges);
|
||||
|
||||
@@ -317,4 +317,43 @@ suite('NotebookCellList', () => {
|
||||
assert.deepStrictEqual(cellList.scrollTop, 60);
|
||||
});
|
||||
});
|
||||
|
||||
test('visibleRanges should be exclusive of end', async function () {
|
||||
await withTestNotebook(
|
||||
[
|
||||
],
|
||||
async (editor, viewModel) => {
|
||||
const cellList = createNotebookCellList(instantiationService);
|
||||
cellList.attachViewModel(viewModel);
|
||||
|
||||
// render height 210, it can render 3 full cells and 1 partial cell
|
||||
cellList.layout(100, 100);
|
||||
|
||||
assert.deepStrictEqual(cellList.visibleRanges, []);
|
||||
});
|
||||
});
|
||||
|
||||
test('visibleRanges should be exclusive of end 2', async function () {
|
||||
await withTestNotebook(
|
||||
[
|
||||
['# header a', 'markdown', CellKind.Markup, [], {}],
|
||||
],
|
||||
async (editor, viewModel) => {
|
||||
viewModel.restoreEditorViewState({
|
||||
editingCells: [false],
|
||||
editorViewStates: [null],
|
||||
cellTotalHeights: [50],
|
||||
collapsedInputCells: {},
|
||||
collapsedOutputCells: {},
|
||||
});
|
||||
|
||||
const cellList = createNotebookCellList(instantiationService);
|
||||
cellList.attachViewModel(viewModel);
|
||||
|
||||
// render height 210, it can render 3 full cells and 1 partial cell
|
||||
cellList.layout(100, 100);
|
||||
|
||||
assert.deepStrictEqual(cellList.visibleRanges, [{ start: 0, end: 1 }]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user