diff --git a/src/vs/workbench/contrib/notebook/browser/view/renderers/codeCell.ts b/src/vs/workbench/contrib/notebook/browser/view/renderers/codeCell.ts index 23dbf910225..a54010e4550 100644 --- a/src/vs/workbench/contrib/notebook/browser/view/renderers/codeCell.ts +++ b/src/vs/workbench/contrib/notebook/browser/view/renderers/codeCell.ts @@ -130,7 +130,12 @@ export class CodeCell extends Disposable { } })); - this._register(templateData.editor!.onDidChangeCursorSelection(() => { + this._register(templateData.editor!.onDidChangeCursorSelection((e) => { + if (e.source === 'restoreState') { + // do not reveal the cell into view if this selection change was caused by restoring editors... + return; + } + const primarySelection = templateData.editor!.getSelection(); if (primarySelection) { diff --git a/src/vs/workbench/contrib/notebook/browser/view/renderers/markdownCell.ts b/src/vs/workbench/contrib/notebook/browser/view/renderers/markdownCell.ts index 5501828c929..a4ba18a9979 100644 --- a/src/vs/workbench/contrib/notebook/browser/view/renderers/markdownCell.ts +++ b/src/vs/workbench/contrib/notebook/browser/view/renderers/markdownCell.ts @@ -180,6 +180,19 @@ export class StatefullMarkdownCell extends Disposable { } })); + this.localDisposables.add(this.editor!.onDidChangeCursorSelection((e) => { + if (e.source === 'restoreState') { + // do not reveal the cell into view if this selection change was caused by restoring editors... + return; + } + + const primarySelection = this.editor!.getSelection(); + + if (primarySelection) { + this.notebookEditor.revealLineInView(this.viewCell, primarySelection!.positionLineNumber); + } + })); + let cellWidthResizeObserver = getResizesObserver(this.templateData.editingContainer!, dimension, () => { let newWidth = cellWidthResizeObserver.getWidth(); let realContentHeight = this.editor!.getContentHeight();