load document with editor id.

This commit is contained in:
rebornix
2020-05-18 18:03:58 -07:00
parent 4c54f7124c
commit d9fd263f52
3 changed files with 20 additions and 4 deletions

View File

@@ -152,6 +152,10 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo
}
registerListeners() {
this._notebookService.listNotebookEditors().forEach((e) => {
this._addNotebookEditor(e);
});
this._register(this._notebookService.onDidChangeActiveEditor(e => {
this._proxy.$acceptDocumentAndEditorsDelta({
newActiveEditor: e
@@ -185,6 +189,10 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo
this._register(this.accessibilityService.onDidChangeScreenReaderOptimized(() => {
updateOrder();
}));
const activeEditorPane = this.editorService.activeEditorPane as any | undefined;
const notebookEditor = activeEditorPane?.isNotebookEditor ? activeEditorPane.getControl() : undefined;
this._updateState(notebookEditor);
}
async addNotebookDocument(data: INotebookModelAddedData) {
@@ -196,10 +204,14 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo
private _addNotebookEditor(e: IEditor) {
this._toDisposeOnEditorRemove.set(e.getId(), combinedDisposable(
e.onDidChangeModel(() => this._updateState()),
e.onDidFocusEditorWidget(() => this._updateState(e)),
e.onDidFocusEditorWidget(() => {
this._updateState(e);
}),
));
this._updateState();
const activeEditorPane = this.editorService.activeEditorPane as any | undefined;
const notebookEditor = activeEditorPane?.isNotebookEditor ? activeEditorPane.getControl() : undefined;
this._updateState(notebookEditor);
}
private _removeNotebookEditor(e: IEditor) {
@@ -229,6 +241,10 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo
}
}
if (!activeEditor && focusedNotebookEditor) {
activeEditor = focusedNotebookEditor.getId();
}
// editors always have view model attached, which means there is already a document in exthost.
const newState = new DocumentAndEditorState(documents, editors, activeEditor);
const delta = DocumentAndEditorState.compute(this._currentState, newState);