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

add 'snippetOrder' property, #9286

上级 e19c5046
...@@ -261,6 +261,7 @@ class InternalEditorOptionsHelper { ...@@ -261,6 +261,7 @@ class InternalEditorOptionsHelper {
formatOnType: toBoolean(opts.formatOnType), formatOnType: toBoolean(opts.formatOnType),
suggestOnTriggerCharacters: toBoolean(opts.suggestOnTriggerCharacters), suggestOnTriggerCharacters: toBoolean(opts.suggestOnTriggerCharacters),
acceptSuggestionOnEnter: toBoolean(opts.acceptSuggestionOnEnter), acceptSuggestionOnEnter: toBoolean(opts.acceptSuggestionOnEnter),
snippetOrder: opts.snippetOrder,
selectionHighlight: toBoolean(opts.selectionHighlight), selectionHighlight: toBoolean(opts.selectionHighlight),
referenceInfos: toBoolean(opts.referenceInfos), referenceInfos: toBoolean(opts.referenceInfos),
folding: toBoolean(opts.folding), folding: toBoolean(opts.folding),
...@@ -707,6 +708,12 @@ let editorConfiguration:IConfigurationNode = { ...@@ -707,6 +708,12 @@ let editorConfiguration:IConfigurationNode = {
'default': DefaultConfig.editor.acceptSuggestionOnEnter, '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.") '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' : { 'editor.selectionHighlight' : {
'type': 'boolean', 'type': 'boolean',
'default': DefaultConfig.editor.selectionHighlight, 'default': DefaultConfig.editor.selectionHighlight,
......
...@@ -83,6 +83,7 @@ class ConfigClass implements IConfiguration { ...@@ -83,6 +83,7 @@ class ConfigClass implements IConfiguration {
formatOnType: false, formatOnType: false,
suggestOnTriggerCharacters: true, suggestOnTriggerCharacters: true,
acceptSuggestionOnEnter: true, acceptSuggestionOnEnter: true,
snippetOrder: 'normal',
selectionHighlight: true, selectionHighlight: true,
referenceInfos: true, referenceInfos: true,
folding: true, folding: true,
......
...@@ -388,6 +388,10 @@ export interface IEditorOptions { ...@@ -388,6 +388,10 @@ export interface IEditorOptions {
* Defaults to true. * Defaults to true.
*/ */
acceptSuggestionOnEnter?: boolean; acceptSuggestionOnEnter?: boolean;
/**
* Snippet sort order. Defaults to 'normal'.
*/
snippetOrder?: 'top' | 'bottom' | 'normal';
/** /**
* Enable selection highlight. * Enable selection highlight.
* Defaults to true. * Defaults to true.
...@@ -797,6 +801,7 @@ export class EditorContribOptions { ...@@ -797,6 +801,7 @@ export class EditorContribOptions {
formatOnType:boolean; formatOnType:boolean;
suggestOnTriggerCharacters: boolean; suggestOnTriggerCharacters: boolean;
acceptSuggestionOnEnter: boolean; acceptSuggestionOnEnter: boolean;
snippetOrder: 'top' | 'bottom' | 'normal';
selectionHighlight:boolean; selectionHighlight:boolean;
referenceInfos: boolean; referenceInfos: boolean;
folding: boolean; folding: boolean;
...@@ -815,6 +820,7 @@ export class EditorContribOptions { ...@@ -815,6 +820,7 @@ export class EditorContribOptions {
formatOnType:boolean; formatOnType:boolean;
suggestOnTriggerCharacters: boolean; suggestOnTriggerCharacters: boolean;
acceptSuggestionOnEnter: boolean; acceptSuggestionOnEnter: boolean;
snippetOrder: 'top' | 'bottom' | 'normal';
selectionHighlight:boolean; selectionHighlight:boolean;
referenceInfos: boolean; referenceInfos: boolean;
folding: boolean; folding: boolean;
...@@ -829,6 +835,7 @@ export class EditorContribOptions { ...@@ -829,6 +835,7 @@ export class EditorContribOptions {
this.formatOnType = Boolean(source.formatOnType); this.formatOnType = Boolean(source.formatOnType);
this.suggestOnTriggerCharacters = Boolean(source.suggestOnTriggerCharacters); this.suggestOnTriggerCharacters = Boolean(source.suggestOnTriggerCharacters);
this.acceptSuggestionOnEnter = Boolean(source.acceptSuggestionOnEnter); this.acceptSuggestionOnEnter = Boolean(source.acceptSuggestionOnEnter);
this.snippetOrder = (source.snippetOrder || 'normal');
this.selectionHighlight = Boolean(source.selectionHighlight); this.selectionHighlight = Boolean(source.selectionHighlight);
this.referenceInfos = Boolean(source.referenceInfos); this.referenceInfos = Boolean(source.referenceInfos);
this.folding = Boolean(source.folding); this.folding = Boolean(source.folding);
...@@ -849,6 +856,7 @@ export class EditorContribOptions { ...@@ -849,6 +856,7 @@ export class EditorContribOptions {
&& this.formatOnType === other.formatOnType && this.formatOnType === other.formatOnType
&& this.suggestOnTriggerCharacters === other.suggestOnTriggerCharacters && this.suggestOnTriggerCharacters === other.suggestOnTriggerCharacters
&& this.acceptSuggestionOnEnter === other.acceptSuggestionOnEnter && this.acceptSuggestionOnEnter === other.acceptSuggestionOnEnter
&& this.snippetOrder === other.snippetOrder
&& this.selectionHighlight === other.selectionHighlight && this.selectionHighlight === other.selectionHighlight
&& this.referenceInfos === other.referenceInfos && this.referenceInfos === other.referenceInfos
&& this.folding === other.folding && this.folding === other.folding
......
...@@ -379,7 +379,14 @@ export class SuggestModel implements IDisposable { ...@@ -379,7 +379,14 @@ export class SuggestModel implements IDisposable {
isFrozen = true; isFrozen = true;
} }
} else { } 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({ this._onDidSuggest.fire({
......
...@@ -1242,6 +1242,10 @@ declare module monaco.editor { ...@@ -1242,6 +1242,10 @@ declare module monaco.editor {
* Defaults to true. * Defaults to true.
*/ */
acceptSuggestionOnEnter?: boolean; acceptSuggestionOnEnter?: boolean;
/**
* Snippet sort order. Defaults to 'normal'.
*/
snippetOrder?: 'top' | 'bottom' | 'normal';
/** /**
* Enable selection highlight. * Enable selection highlight.
* Defaults to true. * Defaults to true.
...@@ -1404,6 +1408,7 @@ declare module monaco.editor { ...@@ -1404,6 +1408,7 @@ declare module monaco.editor {
formatOnType: boolean; formatOnType: boolean;
suggestOnTriggerCharacters: boolean; suggestOnTriggerCharacters: boolean;
acceptSuggestionOnEnter: boolean; acceptSuggestionOnEnter: boolean;
snippetOrder: 'top' | 'bottom' | 'normal';
selectionHighlight: boolean; selectionHighlight: boolean;
referenceInfos: boolean; referenceInfos: boolean;
folding: boolean; folding: boolean;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册