提交 ca037193 编写于 作者: J Johannes Rieken

add setting editor.gotoLocation.multipleReferences etc and deprecate...

add setting editor.gotoLocation.multipleReferences etc and deprecate editor.gotoLocation.multiple #83752
上级 567ae206
......@@ -1287,6 +1287,8 @@ class EditorFontSize extends SimpleEditorOption<EditorOption.fontSize, number> {
//#region gotoLocation
export type GoToLocationValues = 'peek' | 'gotoAndPeek' | 'goto';
/**
* Configuration options for go to location
*/
......@@ -1294,7 +1296,12 @@ export interface IGotoLocationOptions {
/**
* Control how goto-command work when having multiple results.
*/
multiple?: 'peek' | 'gotoAndPeek' | 'goto';
multiple?: GoToLocationValues;
multipleDefinitions?: GoToLocationValues;
multipleTypeDefinitions?: GoToLocationValues;
multipleDeclarations?: GoToLocationValues;
multipleImplemenations?: GoToLocationValues;
multipleReferences?: GoToLocationValues;
}
export type GoToLocationOptions = Readonly<Required<IGotoLocationOptions>>;
......@@ -1302,20 +1309,49 @@ export type GoToLocationOptions = Readonly<Required<IGotoLocationOptions>>;
class EditorGoToLocation extends BaseEditorOption<EditorOption.gotoLocation, GoToLocationOptions> {
constructor() {
const defaults: GoToLocationOptions = { multiple: 'peek' };
const defaults: GoToLocationOptions = {
multiple: 'peek',
multipleDefinitions: 'peek',
multipleTypeDefinitions: 'peek',
multipleDeclarations: 'peek',
multipleImplemenations: 'peek',
multipleReferences: 'peek',
};
const jsonSubset = {
type: 'string',
enum: ['peek', 'gotoAndPeek', 'goto'],
default: defaults.multiple,
enumDescriptions: [
nls.localize('editor.gotoLocation.multiple.peek', 'Show peek view of the results (default)'),
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 enable peek-less navigation to others')
]
};
super(
EditorOption.gotoLocation, 'gotoLocation', defaults,
{
'editor.gotoLocation.multiple': {
description: nls.localize('editor.gotoLocation.multiple', "Controls the behavior of 'Go To' commands, like Go To Definition, when multiple target locations exist."),
type: 'string',
enum: ['peek', 'gotoAndPeek', 'goto'],
default: defaults.multiple,
enumDescriptions: [
nls.localize('editor.gotoLocation.multiple.peek', 'Show peek view of the results (default)'),
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 enable peek-less navigation to others')
]
deprecationMessage: nls.localize('editor.gotoLocation.multiple.deprecated', "This setting is deprecated, please use separate settings like 'editor.editor.gotoLocation.multipleDefinitions' or 'editor.editor.gotoLocation.multipleImplemenations' instead."),
},
'editor.gotoLocation.multipleDefinitions': {
description: nls.localize('editor.editor.gotoLocation.multipleDefinitions', "Controls the behavior the 'Go to Definition'-command when multiple target locations exist."),
...jsonSubset,
},
'editor.gotoLocation.multipleTypeDefinitions': {
description: nls.localize('editor.editor.gotoLocation.multipleTypeDefinitions', "Controls the behavior the 'Go to Type Definition'-command when multiple target locations exist."),
...jsonSubset,
},
'editor.gotoLocation.multipleDeclarations': {
description: nls.localize('editor.editor.gotoLocation.multipleDeclarations', "Controls the behavior the 'Go to Declaration'-command when multiple target locations exist."),
...jsonSubset,
},
'editor.gotoLocation.multipleImplemenations': {
description: nls.localize('editor.editor.gotoLocation.multipleImplemenattions', "Controls the behavior the 'Go to Implemenations'-command when multiple target locations exist."),
...jsonSubset,
},
'editor.gotoLocation.multipleReferences': {
description: nls.localize('editor.editor.gotoLocation.multipleReferences', "Controls the behavior the 'Go to References'-command when multiple target locations exist."),
...jsonSubset,
},
}
);
......@@ -1327,7 +1363,12 @@ class EditorGoToLocation extends BaseEditorOption<EditorOption.gotoLocation, GoT
}
const input = _input as IGotoLocationOptions;
return {
multiple: EditorStringEnumOption.stringSet<'peek' | 'gotoAndPeek' | 'goto'>(input.multiple, this.defaultValue.multiple, ['peek', 'gotoAndPeek', 'goto'])
multiple: EditorStringEnumOption.stringSet<GoToLocationValues>(input.multiple, this.defaultValue.multiple!, ['peek', 'gotoAndPeek', 'goto']),
multipleDefinitions: input.multipleDefinitions ?? EditorStringEnumOption.stringSet<GoToLocationValues>(input.multipleDefinitions, 'peek', ['peek', 'gotoAndPeek', 'goto']),
multipleTypeDefinitions: input.multipleTypeDefinitions ?? EditorStringEnumOption.stringSet<GoToLocationValues>(input.multipleTypeDefinitions, 'peek', ['peek', 'gotoAndPeek', 'goto']),
multipleDeclarations: input.multipleDeclarations ?? EditorStringEnumOption.stringSet<GoToLocationValues>(input.multipleDeclarations, 'peek', ['peek', 'gotoAndPeek', 'goto']),
multipleImplemenations: input.multipleImplemenations ?? EditorStringEnumOption.stringSet<GoToLocationValues>(input.multipleImplemenations, 'peek', ['peek', 'gotoAndPeek', 'goto']),
multipleReferences: input.multipleReferences ?? EditorStringEnumOption.stringSet<GoToLocationValues>(input.multipleReferences, 'peek', ['peek', 'gotoAndPeek', 'goto']),
};
}
}
......
......@@ -30,7 +30,7 @@ import { getDefinitionsAtPosition, getImplementationsAtPosition, getTypeDefiniti
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
import { EditorStateCancellationTokenSource, CodeEditorStateFlag } from 'vs/editor/browser/core/editorState';
import { ISymbolNavigationService } from 'vs/editor/contrib/gotoSymbol/symbolNavigation';
import { EditorOption } from 'vs/editor/common/config/editorOptions';
import { EditorOption, GoToLocationValues } from 'vs/editor/common/config/editorOptions';
import { isStandalone } from 'vs/base/browser/browser';
import { URI } from 'vs/base/common/uri';
......@@ -108,16 +108,18 @@ abstract class SymbolNavigationAction extends EditorAction {
protected abstract _getAlternativeCommand(): string;
protected abstract _getGoToPreference(editor: IActiveCodeEditor): GoToLocationValues;
private async _onResult(editorService: ICodeEditorService, symbolNavService: ISymbolNavigationService, editor: IActiveCodeEditor, model: ReferencesModel): Promise<void> {
const gotoLocation = editor.getOption(EditorOption.gotoLocation);
if (this._configuration.openInPeek || (gotoLocation.multiple === 'peek' && model.references.length > 1)) {
const gotoLocation = this._getGoToPreference(editor);
if (this._configuration.openInPeek || (gotoLocation === 'peek' && model.references.length > 1)) {
this._openInPeek(editorService, editor, model);
} else {
const next = model.firstReference()!;
const targetEditor = await this._openReference(editor, editorService, next, this._configuration.openToSide);
if (targetEditor && model.references.length > 1 && gotoLocation.multiple === 'gotoAndPeek') {
if (targetEditor && model.references.length > 1 && gotoLocation === 'gotoAndPeek') {
this._openInPeek(editorService, targetEditor, model);
} else {
model.dispose();
......@@ -125,7 +127,7 @@ abstract class SymbolNavigationAction extends EditorAction {
// keep remaining locations around when using
// 'goto'-mode
if (gotoLocation.multiple === 'goto') {
if (gotoLocation === 'goto') {
symbolNavService.put(next);
}
}
......@@ -190,6 +192,10 @@ export class DefinitionAction extends SymbolNavigationAction {
protected _getAlternativeCommand(): string {
return 'editor.action.referenceSearch.trigger';
}
protected _getGoToPreference(editor: IActiveCodeEditor): GoToLocationValues {
return editor.getOption(EditorOption.gotoLocation).multipleDefinitions;
}
}
const goToDefinitionKb = isWeb && !isStandalone
......@@ -309,6 +315,10 @@ class DeclarationAction extends SymbolNavigationAction {
protected _getAlternativeCommand(): string {
return 'editor.action.referenceSearch.trigger';
}
protected _getGoToPreference(editor: IActiveCodeEditor): GoToLocationValues {
return editor.getOption(EditorOption.gotoLocation).multipleDeclarations;
}
}
registerEditorAction(class GoToDeclarationAction extends DeclarationAction {
......@@ -390,6 +400,10 @@ class TypeDefinitionAction extends SymbolNavigationAction {
protected _getAlternativeCommand(): string {
return 'editor.action.referenceSearch.trigger';
}
protected _getGoToPreference(editor: IActiveCodeEditor): GoToLocationValues {
return editor.getOption(EditorOption.gotoLocation).multipleTypeDefinitions;
}
}
registerEditorAction(class GoToTypeDefinitionAction extends TypeDefinitionAction {
......@@ -475,6 +489,10 @@ class ImplementationAction extends SymbolNavigationAction {
protected _getAlternativeCommand(): string {
return '';
}
protected _getGoToPreference(editor: IActiveCodeEditor): GoToLocationValues {
return editor.getOption(EditorOption.gotoLocation).multipleImplemenations;
}
}
registerEditorAction(class GoToImplementationAction extends ImplementationAction {
......@@ -561,6 +579,10 @@ class ReferencesAction extends SymbolNavigationAction {
protected _getAlternativeCommand(): string {
return '';
}
protected _getGoToPreference(editor: IActiveCodeEditor): GoToLocationValues {
return editor.getOption(EditorOption.gotoLocation).multipleReferences;
}
}
registerEditorAction(class GoToReferencesAction extends ReferencesAction {
......
......@@ -3060,6 +3060,8 @@ declare namespace monaco.editor {
export type EditorFindOptions = Readonly<Required<IEditorFindOptions>>;
export type GoToLocationValues = 'peek' | 'gotoAndPeek' | 'goto';
/**
* Configuration options for go to location
*/
......@@ -3067,7 +3069,12 @@ declare namespace monaco.editor {
/**
* Control how goto-command work when having multiple results.
*/
multiple?: 'peek' | 'gotoAndPeek' | 'goto';
multiple?: GoToLocationValues;
multipleDefinitions?: GoToLocationValues;
multipleTypeDefinitions?: GoToLocationValues;
multipleDeclarations?: GoToLocationValues;
multipleImplemenations?: GoToLocationValues;
multipleReferences?: GoToLocationValues;
}
export type GoToLocationOptions = Readonly<Required<IGotoLocationOptions>>;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册