提交 a67c8151 编写于 作者: O ozyx

Add option to enable cycling of parameter hints

上级 64c433bf
......@@ -684,6 +684,11 @@ const editorConfiguration: IConfigurationNode = {
'default': EDITOR_DEFAULTS.contribInfo.codeLens,
'description': nls.localize('codeLens', "Controls whether the editor shows CodeLens")
},
'editor.cycleParameterHints': {
'type': 'boolean',
'default': EDITOR_DEFAULTS.contribInfo.cycleParameterHints,
'description': nls.localize('cycleParameterHints', "Controls whether the parameter hints menu cycles or closes when reaching the end of the list.")
},
'editor.folding': {
'type': 'boolean',
'default': EDITOR_DEFAULTS.contribInfo.folding,
......
......@@ -416,6 +416,11 @@ export interface IEditorOptions {
* Defaults to true.
*/
contextmenu?: boolean;
/**
* Enable cycling through parameter hints.
* Defaults to false.
*/
cycleParameterHints?: boolean;
/**
* A multiplier to be used on the `deltaX` and `deltaY` of mouse wheel scroll events.
* Defaults to 1.
......@@ -909,6 +914,7 @@ export interface EditorContribOptions {
readonly hover: InternalEditorHoverOptions;
readonly links: boolean;
readonly contextmenu: boolean;
readonly cycleParameterHints: boolean;
readonly quickSuggestions: boolean | { other: boolean, comments: boolean, strings: boolean };
readonly quickSuggestionsDelay: number;
readonly parameterHints: boolean;
......@@ -1289,6 +1295,7 @@ export class InternalEditorOptions {
&& this._equalsHoverOptions(a.hover, b.hover)
&& a.links === b.links
&& a.contextmenu === b.contextmenu
&& a.cycleParameterHints === b.cycleParameterHints
&& InternalEditorOptions._equalsQuickSuggestions(a.quickSuggestions, b.quickSuggestions)
&& a.quickSuggestionsDelay === b.quickSuggestionsDelay
&& a.parameterHints === b.parameterHints
......@@ -1884,6 +1891,7 @@ export class EditorOptionsValidator {
hover: this._santizeHoverOpts(opts.hover, defaults.hover),
links: _boolean(opts.links, defaults.links),
contextmenu: _boolean(opts.contextmenu, defaults.contextmenu),
cycleParameterHints: _boolean(opts.cycleParameterHints, defaults.cycleParameterHints),
quickSuggestions: quickSuggestions,
quickSuggestionsDelay: _clampedInt(opts.quickSuggestionsDelay, defaults.quickSuggestionsDelay, Constants.MIN_SAFE_SMALL_INTEGER, Constants.MAX_SAFE_SMALL_INTEGER),
parameterHints: _boolean(opts.parameterHints, defaults.parameterHints),
......@@ -1992,6 +2000,7 @@ export class InternalEditorOptionsFactory {
hover: opts.contribInfo.hover,
links: (accessibilityIsOn ? false : opts.contribInfo.links), // DISABLED WHEN SCREEN READER IS ATTACHED
contextmenu: opts.contribInfo.contextmenu,
cycleParameterHints: opts.contribInfo.cycleParameterHints,
quickSuggestions: opts.contribInfo.quickSuggestions,
quickSuggestionsDelay: opts.contribInfo.quickSuggestionsDelay,
parameterHints: opts.contribInfo.parameterHints,
......@@ -2463,6 +2472,7 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
},
links: true,
contextmenu: true,
cycleParameterHints: false,
quickSuggestions: { other: true, comments: false, strings: false },
quickSuggestionsDelay: 10,
parameterHints: true,
......
......@@ -476,14 +476,20 @@ export class ParameterHintsWidget implements IContentWidget, IDisposable {
next(): boolean {
const length = this.hints.signatures.length;
const last = (this.currentSignature % length) === (length - 1);
const cycleParameterHints = this.editor.getConfiguration().contribInfo.cycleParameterHints;
// If there is only one signature, or we're on last signature of list
if (length < 2 || last) {
if ((length < 2 || last) && !cycleParameterHints) {
this.cancel();
return false;
}
this.currentSignature++;
if (last && cycleParameterHints) {
this.currentSignature = 0;
} else {
this.currentSignature++;
}
this.render();
return true;
}
......@@ -491,13 +497,20 @@ export class ParameterHintsWidget implements IContentWidget, IDisposable {
previous(): boolean {
const length = this.hints.signatures.length;
const first = this.currentSignature === 0;
const cycleParameterHints = this.editor.getConfiguration().contribInfo.cycleParameterHints;
if (length < 2 || first) {
// If there is only one signature, or we're on first signature of list
if ((length < 2 || first) && !cycleParameterHints) {
this.cancel();
return false;
}
this.currentSignature--;
if (first && cycleParameterHints) {
this.currentSignature = length - 1;
} else {
this.currentSignature--;
}
this.render();
return true;
}
......
......@@ -2754,6 +2754,11 @@ declare namespace monaco.editor {
* Defaults to true.
*/
contextmenu?: boolean;
/**
* Enable cycling through parameter hints.
* Defaults to false.
*/
cycleParameterHints?: boolean;
/**
* A multiplier to be used on the `deltaX` and `deltaY` of mouse wheel scroll events.
* Defaults to 1.
......@@ -3188,6 +3193,7 @@ declare namespace monaco.editor {
readonly hover: InternalEditorHoverOptions;
readonly links: boolean;
readonly contextmenu: boolean;
readonly cycleParameterHints: boolean;
readonly quickSuggestions: boolean | {
other: boolean;
comments: boolean;
......
......@@ -113,6 +113,7 @@ const configurationValueWhitelist = [
'editor.multiCursorModifier',
'editor.quickSuggestions',
'editor.quickSuggestionsDelay',
'editor.cycleParameterHints',
'editor.parameterHints',
'editor.autoClosingBrackets',
'editor.autoIndent',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册