未验证 提交 1b8c51e6 编写于 作者: J Johannes Rieken 提交者: GitHub

Merge pull request #55354 from ozyx/cycle-parameterHints

Add option to enable cycling of parameter hints
......@@ -83,6 +83,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
this._rawOptions.minimap = objects.mixin({}, this._rawOptions.minimap || {});
this._rawOptions.find = objects.mixin({}, this._rawOptions.find || {});
this._rawOptions.hover = objects.mixin({}, this._rawOptions.hover || {});
this._rawOptions.parameterHints = objects.mixin({}, this._rawOptions.parameterHints || {});
this._validatedOptions = editorOptions.EditorOptionsValidator.validate(this._rawOptions, EDITOR_DEFAULTS);
this.editor = null;
......@@ -488,10 +489,15 @@ const editorConfiguration: IConfigurationNode = {
'minimum': 0,
'description': nls.localize('quickSuggestionsDelay', "Controls the delay in milliseconds after which quick suggestions will show up.")
},
'editor.parameterHints': {
'editor.parameterHints.enabled': {
'type': 'boolean',
'default': EDITOR_DEFAULTS.contribInfo.parameterHints,
'description': nls.localize('parameterHints', "Enables a pop-up that shows parameter documentation and type information as you type.")
'default': EDITOR_DEFAULTS.contribInfo.parameterHints.enabled,
'description': nls.localize('parameterHints.enabled', "Enables a pop-up that shows parameter documentation and type information as you type.")
},
'editor.parameterHints.cycle': {
'type': 'boolean',
'default': EDITOR_DEFAULTS.contribInfo.parameterHints.cycle,
'description': nls.localize('parameterHints.cycle', "Controls whether the parameter hints menu cycles or closes when reaching the end of the list.")
},
'editor.autoClosingBrackets': {
'type': 'boolean',
......
......@@ -158,6 +158,22 @@ export interface IEditorHoverOptions {
sticky?: boolean;
}
/**
* Configuration options for parameter hints
*/
export interface IEditorParameterHintOptions {
/**
* Enable parameter hints.
* Defaults to true.
*/
enabled?: boolean;
/**
* Enable cycling of parameter hints.
* Defaults to false.
*/
cycle?: boolean;
}
export interface ISuggestOptions {
/**
* Enable graceful matching. Defaults to true.
......@@ -451,9 +467,9 @@ export interface IEditorOptions {
*/
quickSuggestionsDelay?: number;
/**
* Enables parameter hints
* Parameter hint options.
*/
parameterHints?: boolean;
parameterHints?: IEditorParameterHintOptions;
/**
* Render icons in suggestions box.
* Defaults to true.
......@@ -851,6 +867,11 @@ export interface InternalSuggestOptions {
readonly snippetsPreventQuickSuggestions: boolean;
}
export interface InternalParameterHintOptions {
readonly enabled: boolean;
readonly cycle: boolean;
}
export interface EditorWrappingInfo {
readonly inDiffEditor: boolean;
readonly isDominatedByLongLines: boolean;
......@@ -911,7 +932,7 @@ export interface EditorContribOptions {
readonly contextmenu: boolean;
readonly quickSuggestions: boolean | { other: boolean, comments: boolean, strings: boolean };
readonly quickSuggestionsDelay: number;
readonly parameterHints: boolean;
readonly parameterHints: InternalParameterHintOptions;
readonly iconsInSuggestions: boolean;
readonly formatOnType: boolean;
readonly formatOnPaste: boolean;
......@@ -1237,6 +1258,16 @@ export class InternalEditorOptions {
);
}
/**
* @internal
*/
private static _equalsParameterHintOptions(a: InternalParameterHintOptions, b: InternalParameterHintOptions): boolean {
return (
a.enabled === b.enabled
&& a.cycle === b.cycle
);
}
/**
* @internal
*/
......@@ -1291,7 +1322,7 @@ export class InternalEditorOptions {
&& a.contextmenu === b.contextmenu
&& InternalEditorOptions._equalsQuickSuggestions(a.quickSuggestions, b.quickSuggestions)
&& a.quickSuggestionsDelay === b.quickSuggestionsDelay
&& a.parameterHints === b.parameterHints
&& this._equalsParameterHintOptions(a.parameterHints, b.parameterHints)
&& a.iconsInSuggestions === b.iconsInSuggestions
&& a.formatOnType === b.formatOnType
&& a.formatOnPaste === b.formatOnPaste
......@@ -1732,6 +1763,17 @@ export class EditorOptionsValidator {
};
}
private static _sanitizeParameterHintOpts(opts: IEditorParameterHintOptions, defaults: InternalParameterHintOptions): InternalParameterHintOptions {
if (typeof opts !== 'object') {
return defaults;
}
return {
enabled: _boolean(opts.enabled, defaults.enabled),
cycle: _boolean(opts.cycle, defaults.cycle)
};
}
private static _santizeHoverOpts(_opts: boolean | IEditorHoverOptions, defaults: InternalEditorHoverOptions): InternalEditorHoverOptions {
let opts: IEditorHoverOptions;
if (typeof _opts === 'boolean') {
......@@ -1884,7 +1926,7 @@ export class EditorOptionsValidator {
contextmenu: _boolean(opts.contextmenu, defaults.contextmenu),
quickSuggestions: quickSuggestions,
quickSuggestionsDelay: _clampedInt(opts.quickSuggestionsDelay, defaults.quickSuggestionsDelay, Constants.MIN_SAFE_SMALL_INTEGER, Constants.MAX_SAFE_SMALL_INTEGER),
parameterHints: _boolean(opts.parameterHints, defaults.parameterHints),
parameterHints: this._sanitizeParameterHintOpts(opts.parameterHints, defaults.parameterHints),
iconsInSuggestions: _boolean(opts.iconsInSuggestions, defaults.iconsInSuggestions),
formatOnType: _boolean(opts.formatOnType, defaults.formatOnType),
formatOnPaste: _boolean(opts.formatOnPaste, defaults.formatOnPaste),
......@@ -2463,7 +2505,10 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
contextmenu: true,
quickSuggestions: { other: true, comments: false, strings: false },
quickSuggestionsDelay: 10,
parameterHints: true,
parameterHints: {
enabled: true,
cycle: false
},
iconsInSuggestions: true,
formatOnType: false,
formatOnPaste: false,
......
......@@ -169,7 +169,7 @@ export class ParameterHintsModel extends Disposable {
}
private onEditorConfigurationChange(): void {
this.enabled = this.editor.getConfiguration().contribInfo.parameterHints;
this.enabled = this.editor.getConfiguration().contribInfo.parameterHints.enabled;
if (!this.enabled) {
this.cancel();
......@@ -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 cycle = this.editor.getConfiguration().contribInfo.parameterHints.cycle;
// If there is only one signature, or we're on last signature of list
if (length < 2 || last) {
if ((length < 2 || last) && !cycle) {
this.cancel();
return false;
}
this.currentSignature++;
if (last && cycle) {
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 cycle = this.editor.getConfiguration().contribInfo.parameterHints.cycle;
if (length < 2 || first) {
// If there is only one signature, or we're on first signature of list
if ((length < 2 || first) && !cycle) {
this.cancel();
return false;
}
this.currentSignature--;
if (first && cycle) {
this.currentSignature = length - 1;
} else {
this.currentSignature--;
}
this.render();
return true;
}
......
......@@ -2508,6 +2508,22 @@ declare namespace monaco.editor {
sticky?: boolean;
}
/**
* Configuration options for parameter hints
*/
export interface IEditorParameterHintOptions {
/**
* Enable parameter hints.
* Defaults to true.
*/
enabled?: boolean;
/**
* Enable cycling of parameter hints.
* Defaults to false.
*/
cycle?: boolean;
}
export interface ISuggestOptions {
/**
* Enable graceful matching. Defaults to true.
......@@ -2793,9 +2809,9 @@ declare namespace monaco.editor {
*/
quickSuggestionsDelay?: number;
/**
* Enables parameter hints
* Parameter hint options.
*/
parameterHints?: boolean;
parameterHints?: IEditorParameterHintOptions;
/**
* Render icons in suggestions box.
* Defaults to true.
......@@ -3130,6 +3146,11 @@ declare namespace monaco.editor {
readonly snippetsPreventQuickSuggestions: boolean;
}
export interface InternalParameterHintOptions {
readonly enabled: boolean;
readonly cycle: boolean;
}
export interface EditorWrappingInfo {
readonly inDiffEditor: boolean;
readonly isDominatedByLongLines: boolean;
......@@ -3194,7 +3215,7 @@ declare namespace monaco.editor {
strings: boolean;
};
readonly quickSuggestionsDelay: number;
readonly parameterHints: boolean;
readonly parameterHints: InternalParameterHintOptions;
readonly iconsInSuggestions: boolean;
readonly formatOnType: boolean;
readonly formatOnPaste: boolean;
......
......@@ -113,7 +113,8 @@ const configurationValueWhitelist = [
'editor.multiCursorModifier',
'editor.quickSuggestions',
'editor.quickSuggestionsDelay',
'editor.parameterHints',
'editor.parameterHints.enabled',
'editor.parameterHints.cycle',
'editor.autoClosingBrackets',
'editor.autoIndent',
'editor.formatOnType',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册