Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intelli-sense in extensions file #26564

Merged
merged 5 commits into from
May 17, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions extensions/configuration-editing/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export function activate(context): void {
//settings.json suggestions
context.subscriptions.push(registerSettingsCompletions());

//extensions.json suggestions
context.subscriptions.push(registerExtensionsCompletions());

// launch.json decorations
context.subscriptions.push(vscode.window.onDidChangeActiveTextEditor(editor => updateLaunchJsonDecorations(editor), null, context.subscriptions));
context.subscriptions.push(vscode.workspace.onDidChangeTextDocument(event => {
Expand Down Expand Up @@ -61,11 +64,25 @@ function registerSettingsCompletions(): vscode.Disposable {
});
}

function newSimpleCompletionItem(text: string, range: vscode.Range, description?: string): vscode.CompletionItem {
function registerExtensionsCompletions(): vscode.Disposable {
return vscode.languages.registerCompletionItemProvider({ pattern: '**/extensions.json' }, {
provideCompletionItems(document, position, token) {
const location = getLocation(document.getText(), document.offsetAt(position));
const range = document.getWordRangeAtPosition(position) || new vscode.Range(position, position);
if (location.path[0] === 'recommendations') {
return vscode.extensions.all
.filter(e => !e.id.startsWith('vscode.'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • You also need to exclude following extension which is packaged along with VS Code - Microsoft.vscode-markdown. This was getting shown in the intelli-sense.

  • Intelli-sense should not show already entered extensions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sandy081

  • Excluded Microsoft.vscode-markdown. Can I exclude all packages starting with Microsoft.vscode- ?
  • Intelli-sense should not show already entered extensions: OK
  • Maybe it's better remove: ExtensionsConfigurationSchema / defaultSnippets / Example ?

.map(e => newSimpleCompletionItem(e.id, range, undefined, '"' + e.id + '"'));
}
}
});
}

function newSimpleCompletionItem(text: string, range: vscode.Range, description?: string, insertText?: string): vscode.CompletionItem {
const item = new vscode.CompletionItem(text);
item.kind = vscode.CompletionItemKind.Value;
item.detail = description;
item.insertText = text;
item.insertText = insertText || text;
item.range = range;

return item;
Expand Down