make getEditorById strict

This commit is contained in:
Johannes Rieken
2021-06-07 17:47:34 +02:00
parent a31c6c3550
commit 8006b8c9a4
4 changed files with 4 additions and 18 deletions

View File

@@ -106,20 +106,14 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
});
}
getEditorById(editorId: string, strict: true): ExtHostNotebookEditor;
getEditorById(editorId: string): ExtHostNotebookEditor | undefined;
getEditorById(editorId: string, strict?: true): ExtHostNotebookEditor | undefined {
getEditorById(editorId: string): ExtHostNotebookEditor {
const editor = this._editors.get(editorId);
if (!editor && strict) {
if (!editor) {
throw new Error(`unknown text editor: ${editorId}. known editors: ${[...this._editors.keys()]} `);
}
return editor;
}
allEditors(): ExtHostNotebookEditor[] {
return [...this._editors.values()];
}
getIdByEditor(editor: vscode.NotebookEditor): string | undefined {
for (const [id, candidate] of this._editors) {
if (candidate.apiEditor === editor) {