From a1f7a1ad7834e1913c7dab515d74d55573a918bd Mon Sep 17 00:00:00 2001 From: rebornix Date: Fri, 27 Mar 2020 11:10:47 -0700 Subject: [PATCH] Fix #93542 --- .../contrib/notebook/browser/notebookEditor.ts | 12 ++++++++++++ .../notebook/browser/viewModel/notebookViewModel.ts | 1 + 2 files changed, 13 insertions(+) diff --git a/src/vs/workbench/contrib/notebook/browser/notebookEditor.ts b/src/vs/workbench/contrib/notebook/browser/notebookEditor.ts index 4c1ed0d9004..c82f940b614 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookEditor.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookEditor.ts @@ -335,6 +335,14 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor { const viewState = this.loadTextEditorViewState(input); this.notebookViewModel.restoreEditorViewState(viewState); + if (viewState?.scrollPosition !== undefined) { + this.list!.scrollTop = viewState!.scrollPosition.top; + this.list!.scrollLeft = viewState!.scrollPosition.left; + } else { + this.list!.scrollTop = 0; + this.list!.scrollLeft = 0; + } + this.localStore.add(this.eventDispatcher.onDidChangeMetadata((e) => { this.editorEditable?.set(e.source.editable); })); @@ -409,6 +417,10 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor { private saveTextEditorViewState(input: NotebookEditorInput): void { if (this.group && this.notebookViewModel) { const state = this.notebookViewModel.saveEditorViewState(); + if (this.list) { + state.scrollPosition = { left: this.list.scrollLeft, top: this.list.scrollTop }; + } + this.editorMemento.saveEditorState(this.group, input.resource, state); } } diff --git a/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts b/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts index a3abfc9388c..84522dd6e25 100644 --- a/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts +++ b/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts @@ -25,6 +25,7 @@ import { NotebookEventDispatcher, NotebookMetadataChangedEvent } from 'vs/workbe export interface INotebookEditorViewState { editingCells: { [key: number]: boolean }; editorViewStates: { [key: number]: editorCommon.ICodeEditorViewState | null }; + scrollPosition?: { left: number; top: number; }; } export interface ICellModelDecorations { -- GitLab