提交 8eeb1f6d 编写于 作者: J Johannes Rieken

add 'snippetOrder' property, #9286

上级 e19c5046
......@@ -261,6 +261,7 @@ class InternalEditorOptionsHelper {
formatOnType: toBoolean(opts.formatOnType),
suggestOnTriggerCharacters: toBoolean(opts.suggestOnTriggerCharacters),
acceptSuggestionOnEnter: toBoolean(opts.acceptSuggestionOnEnter),
snippetOrder: opts.snippetOrder,
selectionHighlight: toBoolean(opts.selectionHighlight),
referenceInfos: toBoolean(opts.referenceInfos),
folding: toBoolean(opts.folding),
......@@ -707,6 +708,12 @@ let editorConfiguration:IConfigurationNode = {
'default': DefaultConfig.editor.acceptSuggestionOnEnter,
'description': nls.localize('acceptSuggestionOnEnter', "Controls if suggestions should be accepted 'Enter' - in addition to 'Tab'. Helps to avoid ambiguity between inserting new lines or accepting suggestions.")
},
'editor.snippetOrder': {
'type': 'string',
'enum': ['top', 'bottom', 'normal'],
'default': 'normal',
'description': nls.localize('snippetOrder', "Controls how snippets are sorted when shown with other suggestions.")
},
'editor.selectionHighlight' : {
'type': 'boolean',
'default': DefaultConfig.editor.selectionHighlight,
......
......@@ -83,6 +83,7 @@ class ConfigClass implements IConfiguration {
formatOnType: false,
suggestOnTriggerCharacters: true,
acceptSuggestionOnEnter: true,
snippetOrder: 'normal',
selectionHighlight: true,
referenceInfos: true,
folding: true,
......
......@@ -388,6 +388,10 @@ export interface IEditorOptions {
* Defaults to true.
*/
acceptSuggestionOnEnter?: boolean;
/**
* Snippet sort order. Defaults to 'normal'.
*/
snippetOrder?: 'top' | 'bottom' | 'normal';
/**
* Enable selection highlight.
* Defaults to true.
......@@ -797,6 +801,7 @@ export class EditorContribOptions {
formatOnType:boolean;
suggestOnTriggerCharacters: boolean;
acceptSuggestionOnEnter: boolean;
snippetOrder: 'top' | 'bottom' | 'normal';
selectionHighlight:boolean;
referenceInfos: boolean;
folding: boolean;
......@@ -815,6 +820,7 @@ export class EditorContribOptions {
formatOnType:boolean;
suggestOnTriggerCharacters: boolean;
acceptSuggestionOnEnter: boolean;
snippetOrder: 'top' | 'bottom' | 'normal';
selectionHighlight:boolean;
referenceInfos: boolean;
folding: boolean;
......@@ -829,6 +835,7 @@ export class EditorContribOptions {
this.formatOnType = Boolean(source.formatOnType);
this.suggestOnTriggerCharacters = Boolean(source.suggestOnTriggerCharacters);
this.acceptSuggestionOnEnter = Boolean(source.acceptSuggestionOnEnter);
this.snippetOrder = (source.snippetOrder || 'normal');
this.selectionHighlight = Boolean(source.selectionHighlight);
this.referenceInfos = Boolean(source.referenceInfos);
this.folding = Boolean(source.folding);
......@@ -849,6 +856,7 @@ export class EditorContribOptions {
&& this.formatOnType === other.formatOnType
&& this.suggestOnTriggerCharacters === other.suggestOnTriggerCharacters
&& this.acceptSuggestionOnEnter === other.acceptSuggestionOnEnter
&& this.snippetOrder === other.snippetOrder
&& this.selectionHighlight === other.selectionHighlight
&& this.referenceInfos === other.referenceInfos
&& this.folding === other.folding
......
......@@ -379,7 +379,14 @@ export class SuggestModel implements IDisposable {
isFrozen = true;
}
} else {
this.completionModel = new CompletionModel(this.raw, ctx.lineContentBefore, CompletionItemComparator.defaultComparator, false);
const sortOrder = this.editor.getConfiguration().contribInfo.snippetOrder;
const comparator = sortOrder === 'top'
? CompletionItemComparator.snippetUpComparator
: sortOrder === 'bottom'
? CompletionItemComparator.snippetDownComparator
: CompletionItemComparator.defaultComparator;
this.completionModel = new CompletionModel(this.raw, ctx.lineContentBefore, comparator, false);
}
this._onDidSuggest.fire({
......
......@@ -1242,6 +1242,10 @@ declare module monaco.editor {
* Defaults to true.
*/
acceptSuggestionOnEnter?: boolean;
/**
* Snippet sort order. Defaults to 'normal'.
*/
snippetOrder?: 'top' | 'bottom' | 'normal';
/**
* Enable selection highlight.
* Defaults to true.
......@@ -1404,6 +1408,7 @@ declare module monaco.editor {
formatOnType: boolean;
suggestOnTriggerCharacters: boolean;
acceptSuggestionOnEnter: boolean;
snippetOrder: 'top' | 'bottom' | 'normal';
selectionHighlight: boolean;
referenceInfos: boolean;
folding: boolean;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册