Code change:
}); }); <del> test('updateElementHeight with anchor #121723: focus element out of viewport', async function () { </del> <ins> test('updateElementHeight with no scrolling', async function () { config.setUserConfiguration(NotebookSetting.scrollToRevealCell, 'none'); await withTestNotebook( [ ['# header a', 'markdown', CellKind.Markup, [], {}], ['var b = 1;', 'javascript', CellKind.Code, [], {}], ['# header b', 'markdown', CellKind.Markup, [], {}], ['var b = 2;', 'javascript', CellKind.Code, [], {}], ['# header c', 'markdown', CellKind.Markup, [], {}] ], async (editor, viewModel, disposables) => { viewModel.restoreEditorViewState({ editingCells: [false, false, false, false, false], editorViewStates: [null, null, null, null, null], cellTotalHeights: [50, 100, 50, 100, 50], cellLineNumberStates: {}, collapsedInputCells: {}, collapsedOutputCells: {}, }); const cellList = createNotebookCellList(instantiationService, disposables); cellList.attachViewModel(viewModel); // render height 210, it can render 3 full cells and 1 partial cell cellList.layout(210, 100); // init scrollTop and scrollBottom assert.deepStrictEqual(cellList.scrollTop, 0); assert.deepStrictEqual(cellList.getViewScrollBottom(), 210); // scroll to 5 cellList.updateElementHeight2(viewModel.cellAt(0)!, 50); cellList.scrollTop = 5; assert.deepStrictEqual(cellList.scrollTop, 5); assert.deepStrictEqual(cellList.getViewScrollBottom(), 215); cellList.setFocus([1]); cellList.updateElementHeight2(viewModel.cellAt(0)!, 100); assert.deepStrictEqual(cellList.scrollHeight, 400); // Any change in cell size should not affect the scroll height with scrollToReveal set to none assert.deepStrictEqual(cellList.scrollTop, 5); cellList.updateElementHeight2(viewModel.cellAt(0)!, 50); assert.deepStrictEqual(cellList.scrollTop, 5); cellList.updateElementHeight2(viewModel.cellAt(0)!, 250); assert.deepStrictEqual(cellList.scrollTop, 5); }); }); test('updateElementHeight with no scroll setting and cell editor focused', async function () { config.setUserConfiguration(NotebookSetting.scrollToRevealCell, 'none'); await withTestNotebook( [ ['# header a', 'markdown', CellKind.Markup, [], {}], ['var b = 1;', 'javascript', CellKind.Code, [], {}], ['# header b', 'markdown', CellKind.Markup, [], {}], ['var b = 2;', 'javascript', CellKind.Code, [], {}], ['# header c', 'markdown', CellKind.Markup, [], {}] ], async (editor, viewModel, disposables) => { viewModel.restoreEditorViewState({ editingCells: [false, false, false, false, false], editorViewStates: [null, null, null, null, null], cellTotalHeights: [50, 100, 50, 100, 50], cellLineNumberStates: {}, collapsedInputCells: {}, collapsedOutputCells: {}, }); const cellList = createNotebookCellList(instantiationService, disposables); cellList.attachViewModel(viewModel); // render height 210, it can render 3 full cells and 1 partial cell cellList.layout(210, 100); // init scrollTop and scrollBottom assert.deepStrictEqual(cellList.scrollTop, 0); assert.deepStrictEqual(cellList.getViewScrollBottom(), 210); cellList.setFocus([1]); editor.focusNotebookCell(cellList.viewModel?.cellAt(1)!, 'editor'); cellList.updateElementHeight2(viewModel.cellAt(0)!, 100); assert.deepStrictEqual(cellList.scrollHeight, 400); // We have the cell editor focused, so we should anchor to that cell assert.deepStrictEqual(cellList.scrollTop, 50); cellList.updateElementHeight2(viewModel.cellAt(0)!, 50); assert.deepStrictEqual(cellList.scrollTop, 0); cellList.updateElementHeight2(viewModel.cellAt(0)!, 250); assert.deepStrictEqual(cellList.scrollTop, 250 + 100 - cellList.renderHeight); }); }); test('updateElementHeight with focused element out of viewport', async function () { </ins> await withTestNotebook( [ ['# header a', 'markdown', CellKind.Markup, [], {}],

Related discussion:
text: Ideas to experiment with: Don't shrink a cell while it is executing -less jumpy as output is replaced change the anchor heuristic from "if the resizing cell is partially visible" to "if the cell's output will shrink out of view" Anchor to a focused cell if the focus is in the cell's editor cc
For the new heuristics we are adding (growing upwards or downwards), they should probably be interrupted the moment users start to scroll, for example, if I scroll manually to a specific position, I would expect the scroll top not to change.
I disagree - That could mean if you have a cell focused and anchored, and you scroll to get it higher in the view, it would then start getting pushed down as the previous cell grows.
If I scroll to get it lower in the view, as I want to read the cells above, and since it's still in the view and focused/anchored, the cells I was reading will then pushed upwards, right? This feels unnatural compared to how browser handles scrolling or Terminal. Terminal scenario might be closer to this, as it usually sticks to the bottom when the shell is streaming outputs, but the very moment we scroll upwards, it stops sticking to the bottom.