mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 19:44:25 +01:00
make getEditorById strict
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -55,7 +55,7 @@ export class ExtHostNotebookEditors implements ExtHostNotebookEditorsShape {
|
||||
|
||||
$acceptEditorPropertiesChanged(id: string, data: INotebookEditorPropertiesChangeData): void {
|
||||
this._logService.debug('ExtHostNotebook#$acceptEditorPropertiesChanged', id, data);
|
||||
const editor = this._notebooksAndEditors.getEditorById(id, true);
|
||||
const editor = this._notebooksAndEditors.getEditorById(id);
|
||||
// ONE: make all state updates
|
||||
if (data.visibleRanges) {
|
||||
editor._acceptVisibleRanges(data.visibleRanges.ranges.map(typeConverters.NotebookRange.to));
|
||||
@@ -81,7 +81,7 @@ export class ExtHostNotebookEditors implements ExtHostNotebookEditorsShape {
|
||||
|
||||
$acceptEditorViewColumns(data: INotebookEditorViewColumnInfo): void {
|
||||
for (const id in data) {
|
||||
const editor = this._notebooksAndEditors.getEditorById(id, true);
|
||||
const editor = this._notebooksAndEditors.getEditorById(id);
|
||||
editor._acceptViewColumn(typeConverters.ViewColumn.to(data[id]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,10 +286,6 @@ export class ExtHostNotebookKernels implements ExtHostNotebookKernelsShape {
|
||||
}
|
||||
|
||||
const editor = this._extHostNotebook.getEditorById(editorId);
|
||||
if (!editor) {
|
||||
throw new Error(`send message for UNKNOWN editor: ${editorId}`);
|
||||
}
|
||||
|
||||
obj.onDidReceiveMessage.fire(Object.freeze({ editor: editor.apiEditor, message }));
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,6 @@ export class ExtHostNotebookRenderers implements ExtHostNotebookRenderersShape {
|
||||
|
||||
public $postRendererMessage(editorId: string, rendererId: string, message: unknown): void {
|
||||
const editor = this._extHostNotebook.getEditorById(editorId);
|
||||
if (!editor) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._rendererMessageEmitters.get(rendererId)?.fire({ editor: editor.apiEditor, message });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user