Skip to content

Commit befd696

Browse files
committed
use nearestReference also when going to a definition, microsoft#5893
1 parent 1429ec0 commit befd696

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export class DefinitionAction extends EditorAction {
112112
return;
113113
}
114114

115-
return this._onResult(result);
115+
return this._onResult(new ReferencesModel(result));
116116

117117
}, (err) => {
118118
// report an error
@@ -121,14 +121,14 @@ export class DefinitionAction extends EditorAction {
121121
});
122122
}
123123

124-
private _onResult(references: Location[]) {
124+
private _onResult(model: ReferencesModel) {
125125
if (this._configuration.openInPeek) {
126-
this._openInPeek(this.editor, references);
126+
this._openInPeek(this.editor, model);
127127
} else {
128-
let [first] = references;
129-
this._openReference(first, this._configuration.openToSide).then(editor => {
130-
if (references.length > 1) {
131-
this._openInPeek(editor, references);
128+
let next = model.nearestReference(this.editor.getModel().uri, this.editor.getPosition());
129+
this._openReference(next, this._configuration.openToSide).then(editor => {
130+
if (model.references.length > 1) {
131+
this._openInPeek(editor, model);
132132
}
133133
});
134134
}
@@ -141,9 +141,9 @@ export class DefinitionAction extends EditorAction {
141141
});
142142
}
143143

144-
private _openInPeek(target: editorCommon.ICommonCodeEditor, references: Location[]) {
144+
private _openInPeek(target: editorCommon.ICommonCodeEditor, model: ReferencesModel) {
145145
let controller = ReferencesController.getController(target);
146-
controller.toggleWidget(target.getSelection(), TPromise.as(new ReferencesModel(references)), {
146+
controller.toggleWidget(target.getSelection(), TPromise.as(model), {
147147
getMetaTitle: (model) => {
148148
return model.references.length > 1 && nls.localize('meta.title', " – {0} definitions", model.references.length);
149149
},

0 commit comments

Comments
 (0)