未验证 提交 3190c252 编写于 作者: J Johannes Rieken 提交者: GitHub

Merge pull request #69942 from svipas/max-suggestions-to-show-and-icons

Add showIcons and maxSuggestionsToShow settings
......@@ -679,6 +679,18 @@ const editorConfiguration: IConfigurationNode = {
default: true,
description: nls.localize('suggest.snippetsPreventQuickSuggestions', "Control whether an active snippet prevents quick suggestions.")
},
'editor.suggest.showIcons': {
type: 'boolean',
default: EDITOR_DEFAULTS.contribInfo.suggest.showIcons,
description: nls.localize('suggest.showIcons', "Controls whether to show or hide icons in suggestions.")
},
'editor.suggest.maxSuggestionsToShow': {
type: 'number',
default: EDITOR_DEFAULTS.contribInfo.suggest.maxSuggestionsToShow,
minimum: 1,
maximum: 12,
description: nls.localize('suggest.maxSuggestionsToShow', "Controls how many suggestions to show in suggestions.")
},
'editor.selectionHighlight': {
'type': 'boolean',
'default': EDITOR_DEFAULTS.contribInfo.selectionHighlight,
......
......@@ -199,11 +199,18 @@ export interface ISuggestOptions {
* Favours words that appear close to the cursor.
*/
localityBonus?: boolean;
/**
* Enable using global storage for remembering suggestions.
*/
shareSuggestSelections?: boolean;
/**
* Enable or disable icons in suggestions. Defaults to true.
*/
showIcons?: boolean;
/**
* Max suggestions to show in suggestions. Defaults to 12.
*/
maxSuggestionsToShow?: boolean;
}
/**
......@@ -506,11 +513,6 @@ export interface IEditorOptions {
* Parameter hint options.
*/
parameterHints?: IEditorParameterHintOptions;
/**
* Render icons in suggestions box.
* Defaults to true.
*/
iconsInSuggestions?: boolean;
/**
* Options for auto closing brackets.
* Defaults to language defined behavior.
......@@ -923,6 +925,8 @@ export interface InternalSuggestOptions {
readonly snippetsPreventQuickSuggestions: boolean;
readonly localityBonus: boolean;
readonly shareSuggestSelections: boolean;
readonly showIcons: boolean;
readonly maxSuggestionsToShow: number;
}
export interface InternalParameterHintOptions {
......@@ -993,7 +997,6 @@ export interface EditorContribOptions {
readonly quickSuggestions: boolean | { other: boolean, comments: boolean, strings: boolean };
readonly quickSuggestionsDelay: number;
readonly parameterHints: InternalParameterHintOptions;
readonly iconsInSuggestions: boolean;
readonly formatOnType: boolean;
readonly formatOnPaste: boolean;
readonly suggestOnTriggerCharacters: boolean;
......@@ -1374,7 +1377,9 @@ export class InternalEditorOptions {
&& a.snippets === b.snippets
&& a.snippetsPreventQuickSuggestions === b.snippetsPreventQuickSuggestions
&& a.localityBonus === b.localityBonus
&& a.shareSuggestSelections === b.shareSuggestSelections;
&& a.shareSuggestSelections === b.shareSuggestSelections
&& a.showIcons === b.showIcons
&& a.maxSuggestionsToShow === b.maxSuggestionsToShow;
}
}
......@@ -1407,7 +1412,6 @@ export class InternalEditorOptions {
&& InternalEditorOptions._equalsQuickSuggestions(a.quickSuggestions, b.quickSuggestions)
&& a.quickSuggestionsDelay === b.quickSuggestionsDelay
&& this._equalsParameterHintOptions(a.parameterHints, b.parameterHints)
&& a.iconsInSuggestions === b.iconsInSuggestions
&& a.formatOnType === b.formatOnType
&& a.formatOnPaste === b.formatOnPaste
&& a.suggestOnTriggerCharacters === b.suggestOnTriggerCharacters
......@@ -1907,7 +1911,9 @@ export class EditorOptionsValidator {
snippets: _stringSet<'top' | 'bottom' | 'inline' | 'none'>(opts.snippetSuggestions, defaults.snippets, ['top', 'bottom', 'inline', 'none']),
snippetsPreventQuickSuggestions: _boolean(suggestOpts.snippetsPreventQuickSuggestions, defaults.filterGraceful),
localityBonus: _boolean(suggestOpts.localityBonus, defaults.localityBonus),
shareSuggestSelections: _boolean(suggestOpts.shareSuggestSelections, defaults.shareSuggestSelections)
shareSuggestSelections: _boolean(suggestOpts.shareSuggestSelections, defaults.shareSuggestSelections),
showIcons: _boolean(suggestOpts.showIcons, defaults.showIcons),
maxSuggestionsToShow: _clampedInt(suggestOpts.maxSuggestionsToShow, defaults.maxSuggestionsToShow, 1, 12)
};
}
......@@ -2052,7 +2058,6 @@ export class EditorOptionsValidator {
quickSuggestions: quickSuggestions,
quickSuggestionsDelay: _clampedInt(opts.quickSuggestionsDelay, defaults.quickSuggestionsDelay, Constants.MIN_SAFE_SMALL_INTEGER, Constants.MAX_SAFE_SMALL_INTEGER),
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),
suggestOnTriggerCharacters: _boolean(opts.suggestOnTriggerCharacters, defaults.suggestOnTriggerCharacters),
......@@ -2166,7 +2171,6 @@ export class InternalEditorOptionsFactory {
quickSuggestions: opts.contribInfo.quickSuggestions,
quickSuggestionsDelay: opts.contribInfo.quickSuggestionsDelay,
parameterHints: opts.contribInfo.parameterHints,
iconsInSuggestions: opts.contribInfo.iconsInSuggestions,
formatOnType: opts.contribInfo.formatOnType,
formatOnPaste: opts.contribInfo.formatOnPaste,
suggestOnTriggerCharacters: opts.contribInfo.suggestOnTriggerCharacters,
......@@ -2651,7 +2655,6 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
enabled: true,
cycle: false
},
iconsInSuggestions: true,
formatOnType: false,
formatOnPaste: false,
suggestOnTriggerCharacters: true,
......@@ -2667,7 +2670,9 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
snippets: 'inline',
snippetsPreventQuickSuggestions: true,
localityBonus: false,
shareSuggestSelections: false
shareSuggestSelections: false,
showIcons: true,
maxSuggestionsToShow: 12
},
selectionHighlight: true,
occurrencesHighlight: true,
......
......@@ -40,7 +40,6 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { FileKind } from 'vs/platform/files/common/files';
const expandSuggestionDocsByDefault = false;
const maxSuggestionsToShow = 12;
interface ISuggestionTemplateData {
root: HTMLElement;
......@@ -466,14 +465,14 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<Compl
this.storageService = storageService;
this.element = $('.editor-widget.suggest-widget');
if (!this.editor.getConfiguration().contribInfo.iconsInSuggestions) {
addClass(this.element, 'no-icons');
}
this.messageElement = append(this.element, $('.message'));
this.listElement = append(this.element, $('.tree'));
this.details = new SuggestionDetails(this.element, this, this.editor, markdownRenderer, triggerKeybindingLabel);
const applyIconStyle = () => toggleClass(this.element, 'no-icons', !this.editor.getConfiguration().contribInfo.suggest.showIcons);
applyIconStyle();
let renderer = instantiationService.createInstance(Renderer, this, this.editor, triggerKeybindingLabel);
this.list = new List(this.listElement, this, [renderer], {
......@@ -492,7 +491,8 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<Compl
this.list.onMouseDown(e => this.onListMouseDown(e)),
this.list.onSelectionChange(e => this.onListSelection(e)),
this.list.onFocusChange(e => this.onListFocus(e)),
this.editor.onDidChangeCursorSelection(() => this.onCursorSelectionChanged())
this.editor.onDidChangeCursorSelection(() => this.onCursorSelectionChanged()),
this.editor.onDidChangeConfiguration(e => e.contribInfo && applyIconStyle())
];
this.suggestWidgetVisible = SuggestContext.Visible.bindTo(contextKeyService);
......@@ -1037,6 +1037,7 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<Compl
height = this.unfocusedHeight;
} else {
const suggestionCount = this.list.contentHeight / this.unfocusedHeight;
const maxSuggestionsToShow = this.editor.getConfiguration().contribInfo.suggest.maxSuggestionsToShow;
height = Math.min(suggestionCount, maxSuggestionsToShow) * this.unfocusedHeight;
}
......@@ -1117,7 +1118,7 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<Compl
// Heights
private get maxWidgetHeight(): number {
return this.unfocusedHeight * maxSuggestionsToShow;
return this.unfocusedHeight * this.editor.getConfiguration().contribInfo.suggest.maxSuggestionsToShow;
}
private get unfocusedHeight(): number {
......
......@@ -157,7 +157,15 @@ suite('CompletionModel', function () {
], 1, {
leadingLineContent: 's',
characterCountDelta: 0
}, WordDistance.None, { snippets: 'top', snippetsPreventQuickSuggestions: true, filterGraceful: true, localityBonus: false, shareSuggestSelections: false });
}, WordDistance.None, {
snippets: 'top',
snippetsPreventQuickSuggestions: true,
filterGraceful: true,
localityBonus: false,
shareSuggestSelections: false,
showIcons: true,
maxSuggestionsToShow: 12
});
assert.equal(model.items.length, 2);
const [a, b] = model.items;
......@@ -176,7 +184,15 @@ suite('CompletionModel', function () {
], 1, {
leadingLineContent: 's',
characterCountDelta: 0
}, WordDistance.None, { snippets: 'bottom', snippetsPreventQuickSuggestions: true, filterGraceful: true, localityBonus: false, shareSuggestSelections: false });
}, WordDistance.None, {
snippets: 'bottom',
snippetsPreventQuickSuggestions: true,
filterGraceful: true,
localityBonus: false,
shareSuggestSelections: false,
showIcons: true,
maxSuggestionsToShow: 12
});
assert.equal(model.items.length, 2);
const [a, b] = model.items;
......@@ -194,7 +210,15 @@ suite('CompletionModel', function () {
], 1, {
leadingLineContent: 's',
characterCountDelta: 0
}, WordDistance.None, { snippets: 'inline', snippetsPreventQuickSuggestions: true, filterGraceful: true, localityBonus: false, shareSuggestSelections: false });
}, WordDistance.None, {
snippets: 'inline',
snippetsPreventQuickSuggestions: true,
filterGraceful: true,
localityBonus: false,
shareSuggestSelections: false,
showIcons: true,
maxSuggestionsToShow: 12
});
assert.equal(model.items.length, 2);
const [a, b] = model.items;
......
......@@ -2547,6 +2547,14 @@ declare namespace monaco.editor {
* Enable using global storage for remembering suggestions.
*/
shareSuggestSelections?: boolean;
/**
* Enable or disable icons in suggestions. Defaults to true.
*/
showIcons?: boolean;
/**
* Max suggestions to show in suggestions. Defaults to 12.
*/
maxSuggestionsToShow?: boolean;
}
/**
......@@ -2841,11 +2849,6 @@ declare namespace monaco.editor {
* Parameter hint options.
*/
parameterHints?: IEditorParameterHintOptions;
/**
* Render icons in suggestions box.
* Defaults to true.
*/
iconsInSuggestions?: boolean;
/**
* Options for auto closing brackets.
* Defaults to language defined behavior.
......@@ -3195,6 +3198,8 @@ declare namespace monaco.editor {
readonly snippetsPreventQuickSuggestions: boolean;
readonly localityBonus: boolean;
readonly shareSuggestSelections: boolean;
readonly showIcons: boolean;
readonly maxSuggestionsToShow: number;
}
export interface InternalParameterHintOptions {
......@@ -3269,7 +3274,6 @@ declare namespace monaco.editor {
};
readonly quickSuggestionsDelay: number;
readonly parameterHints: InternalParameterHintOptions;
readonly iconsInSuggestions: boolean;
readonly formatOnType: boolean;
readonly formatOnPaste: boolean;
readonly suggestOnTriggerCharacters: boolean;
......
......@@ -294,7 +294,6 @@ function getSuggestEnabledInputOptions(ariaLabel?: string): IEditorOptions {
ariaLabel: ariaLabel || '',
snippetSuggestions: 'none',
suggest: { filterGraceful: false },
iconsInSuggestions: false
suggest: { filterGraceful: false, showIcons: false }
};
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册