better error message when editor has changed in-flight, https://github.com/microsoft/vscode/issues/98871

This commit is contained in:
Johannes Rieken
2020-06-10 09:04:24 +02:00
parent f3ffbedd41
commit 17a3e673db
2 changed files with 19 additions and 19 deletions

View File

@@ -54,7 +54,7 @@ export class ExtHostEditors implements ExtHostEditorsShape {
showTextDocument(document: vscode.TextDocument, column: vscode.ViewColumn, preserveFocus: boolean): Promise<vscode.TextEditor>;
showTextDocument(document: vscode.TextDocument, options: { column: vscode.ViewColumn, preserveFocus: boolean, pinned: boolean }): Promise<vscode.TextEditor>;
showTextDocument(document: vscode.TextDocument, columnOrOptions: vscode.ViewColumn | vscode.TextDocumentShowOptions | undefined, preserveFocus?: boolean): Promise<vscode.TextEditor>;
showTextDocument(document: vscode.TextDocument, columnOrOptions: vscode.ViewColumn | vscode.TextDocumentShowOptions | undefined, preserveFocus?: boolean): Promise<vscode.TextEditor> {
async showTextDocument(document: vscode.TextDocument, columnOrOptions: vscode.ViewColumn | vscode.TextDocumentShowOptions | undefined, preserveFocus?: boolean): Promise<vscode.TextEditor> {
let options: ITextDocumentShowOptions;
if (typeof columnOrOptions === 'number') {
options = {
@@ -74,14 +74,18 @@ export class ExtHostEditors implements ExtHostEditorsShape {
};
}
return this._proxy.$tryShowTextDocument(document.uri, options).then(id => {
const editor = id && this._extHostDocumentsAndEditors.getEditor(id);
if (editor) {
return editor;
} else {
throw new Error(`Failed to show text document ${document.uri.toString()}, should show in editor #${id}`);
}
});
const editorId = await this._proxy.$tryShowTextDocument(document.uri, options);
const editor = editorId && this._extHostDocumentsAndEditors.getEditor(editorId);
if (editor) {
return editor;
}
// we have no editor... having an id means that we had an editor
// on the main side and that it isn't the current editor anymore...
if (editorId) {
throw new Error(`Could NOT open editor for "${document.uri.toString()}" because another editor opened in the meantime.`);
} else {
throw new Error(`Could NOT open editor for "${document.uri.toString()}".`);
}
}
createTextEditorDecorationType(options: vscode.DecorationRenderOptions): vscode.TextEditorDecorationType {