make sure to await showing of results, #65809

pull/65790/head
Johannes Rieken 2019-01-03 11:16:25 +01:00
parent 08510a5b25
commit 2dd7693127
1 changed files with 11 additions and 12 deletions

View File

@ -59,7 +59,7 @@ export class DefinitionAction extends EditorAction {
const model = editor.getModel();
const pos = editor.getPosition();
const definitionPromise = this._getTargetLocationForPosition(model, pos, CancellationToken.None).then(references => {
const definitionPromise = this._getTargetLocationForPosition(model, pos, CancellationToken.None).then(async references => {
if (model.isDisposed() || editor.getModel() !== model) {
// new model, no more model
@ -98,11 +98,11 @@ export class DefinitionAction extends EditorAction {
} else if (result.length === 1 && idxOfCurrent !== -1) {
// only the position at which we are -> adjust selection
let [current] = result;
this._openReference(editor, editorService, current, false);
return this._openReference(editor, editorService, current, false).then(() => undefined);
} else {
// handle multile results
this._onResult(editorService, editor, new ReferencesModel(result));
return this._onResult(editorService, editor, new ReferencesModel(result));
}
}, (err) => {
@ -128,7 +128,7 @@ export class DefinitionAction extends EditorAction {
return model.references.length > 1 && nls.localize('meta.title', " {0} definitions", model.references.length);
}
private _onResult(editorService: ICodeEditorService, editor: ICodeEditor, model: ReferencesModel) {
private async _onResult(editorService: ICodeEditorService, editor: ICodeEditor, model: ReferencesModel): Promise<void> {
const msg = model.getAriaMessage();
alert(msg);
@ -136,14 +136,13 @@ export class DefinitionAction extends EditorAction {
if (this._configuration.openInPeek) {
this._openInPeek(editorService, editor, model);
} else {
let next = model.nearestReference(editor.getModel().uri, editor.getPosition());
this._openReference(editor, editorService, next, this._configuration.openToSide).then(editor => {
if (editor && model.references.length > 1) {
this._openInPeek(editorService, editor, model);
} else {
model.dispose();
}
});
const next = model.nearestReference(editor.getModel().uri, editor.getPosition());
const targetEditor = await this._openReference(editor, editorService, next, this._configuration.openToSide);
if (targetEditor && model.references.length > 1) {
this._openInPeek(editorService, targetEditor, model);
} else {
model.dispose();
}
}
}