@@ -21,6 +21,9 @@ export function activate(context: vscode.ExtensionContext): void {
2121 // task.json variable suggestions
2222 context . subscriptions . push ( registerVariableCompletions ( '**/tasks.json' ) ) ;
2323
24+ // Workspace file launch/tasks variable completions
25+ context . subscriptions . push ( registerVariableCompletions ( '**/*.code-workspace' ) ) ;
26+
2427 // keybindings.json/package.json context key suggestions
2528 context . subscriptions . push ( registerContextKeyCompletions ( ) ) ;
2629}
@@ -38,6 +41,10 @@ function registerVariableCompletions(pattern: string): vscode.Disposable {
3841 provideCompletionItems ( document , position , _token ) {
3942 const location = getLocation ( document . getText ( ) , document . offsetAt ( position ) ) ;
4043 if ( isCompletingInsidePropertyStringValue ( document , location , position ) ) {
44+ if ( document . fileName . endsWith ( '.code-workspace' ) && ! isLocationInsideTopLevelProperty ( location , [ 'launch' , 'tasks' ] ) ) {
45+ return [ ] ;
46+ }
47+
4148 let range = document . getWordRangeAtPosition ( position , / \$ \{ [ ^ " \} ] * \} ? / ) ;
4249 if ( ! range || range . start . isEqual ( position ) || range . end . isEqual ( position ) && document . getText ( range ) . endsWith ( '}' ) ) {
4350 range = new vscode . Range ( position , position ) ;
@@ -84,6 +91,10 @@ function isCompletingInsidePropertyStringValue(document: vscode.TextDocument, lo
8491 return false ;
8592}
8693
94+ function isLocationInsideTopLevelProperty ( location : Location , values : string [ ] ) {
95+ return values . includes ( location . path [ 0 ] as string ) ;
96+ }
97+
8798interface IExtensionsContent {
8899 recommendations : string [ ] ;
89100}
0 commit comments