提交 6c6fcb73 编写于 作者: J Johannes Rieken

fix #71195

上级 732f6661
......@@ -835,8 +835,8 @@ const editorConfiguration: IConfigurationNode = {
default: EDITOR_DEFAULTS.contribInfo.gotoLocation.multiple,
enumDescriptions: [
nls.localize('editor.gotoLocation.multiple.peek', 'Show peek view of the results (default)'),
nls.localize('editor.gotoLocation.multiple.gotoAndPeek', 'Go to the first result and show a peek view'),
nls.localize('editor.gotoLocation.multiple.goto', 'Go to the first result and ignore others')
nls.localize('editor.gotoLocation.multiple.gotoAndPeek', 'Go to the primary result and show a peek view'),
nls.localize('editor.gotoLocation.multiple.goto', 'Go to the primary result and ignore others')
]
},
'editor.selectionHighlight': {
......
......@@ -133,9 +133,12 @@ export class DefinitionAction extends EditorAction {
const { gotoLocation } = editor.getConfiguration().contribInfo;
if (this._configuration.openInPeek || (gotoLocation.multiple === 'peek' && model.references.length > 1)) {
this._openInPeek(editorService, editor, model);
} else if (editor.hasModel()) {
const next = model.nearestReference(editor.getModel().uri, editor.getPosition());
if (next) {
const next = model.firstReference();
if (!next) {
return;
}
const targetEditor = await this._openReference(editor, editorService, next, this._configuration.openToSide);
if (targetEditor && model.references.length > 1 && gotoLocation.multiple === 'gotoAndPeek') {
this._openInPeek(editorService, targetEditor, model);
......@@ -144,7 +147,6 @@ export class DefinitionAction extends EditorAction {
}
}
}
}
private _openReference(editor: ICodeEditor, editorService: ICodeEditorService, reference: Location | LocationLink, sideBySide: boolean): Promise<ICodeEditor | null> {
// range is the target-selection-range when we have one
......
......@@ -23,7 +23,8 @@ export class OneReference {
constructor(
readonly parent: FileReferences,
private _range: IRange
private _range: IRange,
readonly isProviderFirst: boolean
) {
this.id = defaultGenerator.nextId();
}
......@@ -173,6 +174,7 @@ export class ReferencesModel implements IDisposable {
constructor(references: LocationLink[]) {
this._disposables = [];
// grouping and sorting
const [providersFirst] = references;
references.sort(ReferencesModel._compareReferences);
let current: FileReferences | undefined;
......@@ -187,7 +189,7 @@ export class ReferencesModel implements IDisposable {
if (current.children.length === 0
|| !Range.equalsRange(ref.range, current.children[current.children.length - 1].range)) {
let oneRef = new OneReference(current, ref.targetSelectionRange || ref.range);
let oneRef = new OneReference(current, ref.targetSelectionRange || ref.range, providersFirst === ref);
this._disposables.push(oneRef.onRefChanged((e) => this._onDidChangeReferenceRange.fire(e)));
this.references.push(oneRef);
current.children.push(oneRef);
......@@ -267,6 +269,15 @@ export class ReferencesModel implements IDisposable {
return undefined;
}
firstReference(): OneReference | undefined {
for (const ref of this.references) {
if (ref.isProviderFirst) {
return ref;
}
}
return this.references[0];
}
dispose(): void {
dispose(this.groups);
dispose(this._disposables);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册