@@ -21,6 +21,9 @@ export function activate(context: vscode.ExtensionContext): void {
21
21
// task.json variable suggestions
22
22
context . subscriptions . push ( registerVariableCompletions ( '**/tasks.json' ) ) ;
23
23
24
+ // Workspace file launch/tasks variable completions
25
+ context . subscriptions . push ( registerVariableCompletions ( '**/*.code-workspace' ) ) ;
26
+
24
27
// keybindings.json/package.json context key suggestions
25
28
context . subscriptions . push ( registerContextKeyCompletions ( ) ) ;
26
29
}
@@ -38,6 +41,10 @@ function registerVariableCompletions(pattern: string): vscode.Disposable {
38
41
provideCompletionItems ( document , position , _token ) {
39
42
const location = getLocation ( document . getText ( ) , document . offsetAt ( position ) ) ;
40
43
if ( isCompletingInsidePropertyStringValue ( document , location , position ) ) {
44
+ if ( document . fileName . endsWith ( '.code-workspace' ) && ! isLocationInsideTopLevelProperty ( location , [ 'launch' , 'tasks' ] ) ) {
45
+ return [ ] ;
46
+ }
47
+
41
48
let range = document . getWordRangeAtPosition ( position , / \$ \{ [ ^ " \} ] * \} ? / ) ;
42
49
if ( ! range || range . start . isEqual ( position ) || range . end . isEqual ( position ) && document . getText ( range ) . endsWith ( '}' ) ) {
43
50
range = new vscode . Range ( position , position ) ;
@@ -84,6 +91,10 @@ function isCompletingInsidePropertyStringValue(document: vscode.TextDocument, lo
84
91
return false ;
85
92
}
86
93
94
+ function isLocationInsideTopLevelProperty ( location : Location , values : string [ ] ) {
95
+ return values . includes ( location . path [ 0 ] as string ) ;
96
+ }
97
+
87
98
interface IExtensionsContent {
88
99
recommendations : string [ ] ;
89
100
}
0 commit comments