@@ -7,6 +7,7 @@ import { getLocation, parse, visit } from 'jsonc-parser';
77import * as vscode from 'vscode' ;
88import * as nls from 'vscode-nls' ;
99import { SettingsDocument } from './settingsDocumentHelper' ;
10+ import { provideInstalledExtensionProposals } from './extensionsProposals' ;
1011const localize = nls . loadMessageBundle ( ) ;
1112
1213export function activate ( context : vscode . ExtensionContext ) : void {
@@ -80,7 +81,7 @@ function registerExtensionsCompletionsInExtensionsDocument(): vscode.Disposable
8081 const range = document . getWordRangeAtPosition ( position ) || new vscode . Range ( position , position ) ;
8182 if ( location . path [ 0 ] === 'recommendations' ) {
8283 const extensionsContent = < IExtensionsContent > parse ( document . getText ( ) ) ;
83- return provideInstalledExtensionProposals ( extensionsContent , range ) ;
84+ return provideInstalledExtensionProposals ( extensionsContent && extensionsContent . recommendations || [ ] , range , false ) ;
8485 }
8586 return [ ] ;
8687 }
@@ -94,41 +95,13 @@ function registerExtensionsCompletionsInWorkspaceConfigurationDocument(): vscode
9495 const range = document . getWordRangeAtPosition ( position ) || new vscode . Range ( position , position ) ;
9596 if ( location . path [ 0 ] === 'extensions' && location . path [ 1 ] === 'recommendations' ) {
9697 const extensionsContent = < IExtensionsContent > parse ( document . getText ( ) ) [ 'extensions' ] ;
97- return provideInstalledExtensionProposals ( extensionsContent , range ) ;
98+ return provideInstalledExtensionProposals ( extensionsContent && extensionsContent . recommendations || [ ] , range , false ) ;
9899 }
99100 return [ ] ;
100101 }
101102 } ) ;
102103}
103104
104- function provideInstalledExtensionProposals ( extensionsContent : IExtensionsContent , range : vscode . Range ) : vscode . ProviderResult < vscode . CompletionItem [ ] | vscode . CompletionList > {
105- const alreadyEnteredExtensions = extensionsContent && extensionsContent . recommendations || [ ] ;
106- if ( Array . isArray ( alreadyEnteredExtensions ) ) {
107- const knownExtensionProposals = vscode . extensions . all . filter ( e =>
108- ! ( e . id . startsWith ( 'vscode.' )
109- || e . id === 'Microsoft.vscode-markdown'
110- || alreadyEnteredExtensions . indexOf ( e . id ) > - 1 ) ) ;
111- if ( knownExtensionProposals . length ) {
112- return knownExtensionProposals . map ( e => {
113- const item = new vscode . CompletionItem ( e . id ) ;
114- const insertText = `"${ e . id } "` ;
115- item . kind = vscode . CompletionItemKind . Value ;
116- item . insertText = insertText ;
117- item . range = range ;
118- item . filterText = insertText ;
119- return item ;
120- } ) ;
121- } else {
122- const example = new vscode . CompletionItem ( localize ( 'exampleExtension' , "Example" ) ) ;
123- example . insertText = '"vscode.csharp"' ;
124- example . kind = vscode . CompletionItemKind . Value ;
125- example . range = range ;
126- return [ example ] ;
127- }
128- }
129- return undefined ;
130- }
131-
132105vscode . languages . registerDocumentSymbolProvider ( { pattern : '**/launch.json' , language : 'jsonc' } , {
133106 provideDocumentSymbols ( document : vscode . TextDocument , _token : vscode . CancellationToken ) : vscode . ProviderResult < vscode . SymbolInformation [ ] > {
134107 const result : vscode . SymbolInformation [ ] = [ ] ;
0 commit comments