Add trace/error when active nb editor is not in tracked editors map. (#173251)

This commit is contained in:
Peng Lyu
2023-02-02 22:55:11 -08:00
committed by GitHub
parent 99757ba7a5
commit 1e55b31bda
2 changed files with 7 additions and 0 deletions
@@ -7,6 +7,7 @@ import { diffMaps, diffSets } from 'vs/base/common/collections';
import { combinedDisposable, DisposableStore, DisposableMap } from 'vs/base/common/lifecycle';
import { URI } from 'vs/base/common/uri';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ILogService } from 'vs/platform/log/common/log';
import { MainThreadNotebookDocuments } from 'vs/workbench/api/browser/mainThreadNotebookDocuments';
import { NotebookDto } from 'vs/workbench/api/browser/mainThreadNotebookDto';
import { MainThreadNotebookEditors } from 'vs/workbench/api/browser/mainThreadNotebookEditors';
@@ -99,6 +100,7 @@ export class MainThreadNotebooksAndEditors {
@INotebookEditorService private readonly _notebookEditorService: INotebookEditorService,
@IEditorService private readonly _editorService: IEditorService,
@IEditorGroupsService private readonly _editorGroupService: IEditorGroupsService,
@ILogService private readonly _logService: ILogService,
) {
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostNotebook);
@@ -156,6 +158,7 @@ export class MainThreadNotebooksAndEditors {
activeEditor = focusedEditor.getId();
}
if (activeEditor && !editors.has(activeEditor)) {
this._logService.trace('MainThreadNotebooksAndEditors#_updateState: active editor is not in editors list', activeEditor, editors.keys());
activeEditor = null;
}
@@ -424,6 +424,10 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
// clear active notebook as current active editor is non-notebook editor
this._activeNotebookEditor = undefined;
} else if (delta.value.newActiveEditor) {
const activeEditor = this._editors.get(delta.value.newActiveEditor);
if (!activeEditor) {
console.error(`FAILED to find active notebook editor ${delta.value.newActiveEditor}`);
}
this._activeNotebookEditor = this._editors.get(delta.value.newActiveEditor);
}
if (delta.value.newActiveEditor !== undefined) {