Skip to content

Commit

Permalink
add completion item kinds for Issue and User, microsoft#91541
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Mar 19, 2020
1 parent 9ac8206 commit c7293f3
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 30 deletions.
22 changes: 22 additions & 0 deletions src/vs/editor/common/config/editorOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2835,6 +2835,14 @@ export interface ISuggestOptions {
* Show typeParameter-suggestions.
*/
showTypeParameters?: boolean;
/**
* Show issue-suggestions.
*/
showIssues?: boolean;
/**
* Show user-suggestions.
*/
showUsers?: boolean;
/**
* Show snippet-suggestions.
*/
Expand Down Expand Up @@ -2889,6 +2897,8 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, InternalSugge
showFolders: true,
showTypeParameters: true,
showSnippets: true,
showUsers: true,
showIssues: true,
statusBar: {
visible: false
}
Expand Down Expand Up @@ -3077,6 +3087,16 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, InternalSugge
default: true,
markdownDescription: nls.localize('editor.suggest.showSnippets', "When enabled IntelliSense shows `snippet`-suggestions.")
},
'editor.suggest.showUsers': {
type: 'boolean',
default: true,
markdownDescription: nls.localize('editor.suggest.showUsers', "When enabled IntelliSense shows `user`-suggestions.")
},
'editor.suggest.showIssues': {
type: 'boolean',
default: true,
markdownDescription: nls.localize('editor.suggest.showIssues', "When enabled IntelliSense shows `issues`-suggestions.")
},
'editor.suggest.statusBar.visible': {
type: 'boolean',
default: false,
Expand Down Expand Up @@ -3125,6 +3145,8 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, InternalSugge
showFolders: EditorBooleanOption.boolean(input.showFolders, this.defaultValue.showFolders),
showTypeParameters: EditorBooleanOption.boolean(input.showTypeParameters, this.defaultValue.showTypeParameters),
showSnippets: EditorBooleanOption.boolean(input.showSnippets, this.defaultValue.showSnippets),
showUsers: EditorBooleanOption.boolean(input.showUsers, this.defaultValue.showUsers),
showIssues: EditorBooleanOption.boolean(input.showIssues, this.defaultValue.showIssues),
statusBar: {
visible: EditorBooleanOption.boolean(input.statusBar?.visible, !!this.defaultValue.statusBar.visible)
}
Expand Down
59 changes: 32 additions & 27 deletions src/vs/editor/common/modes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ export const enum CompletionItemKind {
Customcolor,
Folder,
TypeParameter,
User,
Issue,
Snippet, // <- highest value (used for compare!)
}

Expand All @@ -327,32 +329,34 @@ export const enum CompletionItemKind {
*/
export const completionKindToCssClass = (function () {
let data = Object.create(null);
data[CompletionItemKind.Method] = 'method';
data[CompletionItemKind.Function] = 'function';
data[CompletionItemKind.Constructor] = 'constructor';
data[CompletionItemKind.Field] = 'field';
data[CompletionItemKind.Variable] = 'variable';
data[CompletionItemKind.Class] = 'class';
data[CompletionItemKind.Struct] = 'struct';
data[CompletionItemKind.Interface] = 'interface';
data[CompletionItemKind.Module] = 'module';
data[CompletionItemKind.Property] = 'property';
data[CompletionItemKind.Event] = 'event';
data[CompletionItemKind.Operator] = 'operator';
data[CompletionItemKind.Unit] = 'unit';
data[CompletionItemKind.Value] = 'value';
data[CompletionItemKind.Constant] = 'constant';
data[CompletionItemKind.Enum] = 'enum';
data[CompletionItemKind.EnumMember] = 'enum-member';
data[CompletionItemKind.Keyword] = 'keyword';
data[CompletionItemKind.Snippet] = 'snippet';
data[CompletionItemKind.Text] = 'text';
data[CompletionItemKind.Color] = 'color';
data[CompletionItemKind.File] = 'file';
data[CompletionItemKind.Reference] = 'reference';
data[CompletionItemKind.Customcolor] = 'customcolor';
data[CompletionItemKind.Folder] = 'folder';
data[CompletionItemKind.TypeParameter] = 'type-parameter';
data[CompletionItemKind.Method] = 'symbol-method';
data[CompletionItemKind.Function] = 'symbol-function';
data[CompletionItemKind.Constructor] = 'symbol-constructor';
data[CompletionItemKind.Field] = 'symbol-field';
data[CompletionItemKind.Variable] = 'symbol-variable';
data[CompletionItemKind.Class] = 'symbol-class';
data[CompletionItemKind.Struct] = 'symbol-struct';
data[CompletionItemKind.Interface] = 'symbol-interface';
data[CompletionItemKind.Module] = 'symbol-module';
data[CompletionItemKind.Property] = 'symbol-property';
data[CompletionItemKind.Event] = 'symbol-event';
data[CompletionItemKind.Operator] = 'symbol-operator';
data[CompletionItemKind.Unit] = 'symbol-unit';
data[CompletionItemKind.Value] = 'symbol-value';
data[CompletionItemKind.Constant] = 'symbol-constant';
data[CompletionItemKind.Enum] = 'symbol-enum';
data[CompletionItemKind.EnumMember] = 'symbol-enum-member';
data[CompletionItemKind.Keyword] = 'symbol-keyword';
data[CompletionItemKind.Snippet] = 'symbol-snippet';
data[CompletionItemKind.Text] = 'symbol-text';
data[CompletionItemKind.Color] = 'symbol-color';
data[CompletionItemKind.File] = 'symbol-file';
data[CompletionItemKind.Reference] = 'symbol-reference';
data[CompletionItemKind.Customcolor] = 'symbol-customcolor';
data[CompletionItemKind.Folder] = 'symbol-folder';
data[CompletionItemKind.TypeParameter] = 'symbol-type-parameter';
data[CompletionItemKind.User] = 'account';
data[CompletionItemKind.Issue] = 'issues';

return function (kind: CompletionItemKind) {
return data[kind] || 'property';
Expand Down Expand Up @@ -395,7 +399,8 @@ export let completionKindFromString: {
data['folder'] = CompletionItemKind.Folder;
data['type-parameter'] = CompletionItemKind.TypeParameter;
data['typeParameter'] = CompletionItemKind.TypeParameter;

data['account'] = CompletionItemKind.User;
data['issue'] = CompletionItemKind.Issue;
return function (value: string, strict?: true) {
let res = data[value];
if (typeof res === 'undefined' && !strict) {
Expand Down
3 changes: 1 addition & 2 deletions src/vs/editor/contrib/suggest/suggestWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ class ItemRenderer implements IListRenderer<CompletionItem, ISuggestionTemplateD
const textLabel = typeof suggestion.label === 'string' ? suggestion.label : suggestion.label.name;

data.root.id = getAriaId(index);
data.icon.className = 'icon ' + completionKindToCssClass(suggestion.kind);
data.colorspan.style.backgroundColor = '';

const labelOptions: IIconLabelValueOptions = {
Expand Down Expand Up @@ -230,7 +229,7 @@ class ItemRenderer implements IListRenderer<CompletionItem, ISuggestionTemplateD
// normal icon
data.icon.className = 'icon hide';
data.iconContainer.className = '';
addClasses(data.iconContainer, `suggest-icon codicon codicon-symbol-${completionKindToCssClass(suggestion.kind)}`);
addClasses(data.iconContainer, `suggest-icon codicon codicon-${completionKindToCssClass(suggestion.kind)}`);
}

if (suggestion.tags && suggestion.tags.indexOf(CompletionItemTag.Deprecated) >= 0) {
Expand Down
9 changes: 9 additions & 0 deletions src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2038,4 +2038,13 @@ declare module 'vscode' {

//#endregion

//#region https://github.com/microsoft/vscode/issues/91541

export enum CompletionItemKind {
User = 25,
Issue = 26,
}

//#endregion

}
4 changes: 4 additions & 0 deletions src/vs/workbench/api/common/extHostTypeConverters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,8 @@ export namespace CompletionItemKind {
case types.CompletionItemKind.Event: return modes.CompletionItemKind.Event;
case types.CompletionItemKind.Operator: return modes.CompletionItemKind.Operator;
case types.CompletionItemKind.TypeParameter: return modes.CompletionItemKind.TypeParameter;
case types.CompletionItemKind.Issue: return modes.CompletionItemKind.Issue;
case types.CompletionItemKind.User: return modes.CompletionItemKind.User;
}
return modes.CompletionItemKind.Property;
}
Expand Down Expand Up @@ -866,6 +868,8 @@ export namespace CompletionItemKind {
case modes.CompletionItemKind.Event: return types.CompletionItemKind.Event;
case modes.CompletionItemKind.Operator: return types.CompletionItemKind.Operator;
case modes.CompletionItemKind.TypeParameter: return types.CompletionItemKind.TypeParameter;
case modes.CompletionItemKind.User: return types.CompletionItemKind.User;
case modes.CompletionItemKind.Issue: return types.CompletionItemKind.Issue;
}
return types.CompletionItemKind.Property;
}
Expand Down
4 changes: 3 additions & 1 deletion src/vs/workbench/api/common/extHostTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,9 @@ export enum CompletionItemKind {
Struct = 21,
Event = 22,
Operator = 23,
TypeParameter = 24
TypeParameter = 24,
User = 25,
Issue = 26
}

export enum CompletionItemTag {
Expand Down

0 comments on commit c7293f3

Please sign in to comment.