@@ -125,23 +125,49 @@ export async function activate(context: vscode.ExtensionContext): Promise<Terraf
125
125
await clientHandler . startClients ( ) ;
126
126
}
127
127
} ) ,
128
- vscode . window . onDidChangeVisibleTextEditors ( async ( ) => {
129
- const textEditor = getActiveTextEditor ( ) ;
130
- if ( textEditor === undefined ) {
131
- return ;
132
- }
133
- if ( textEditor . document === undefined ) {
134
- return ;
135
- }
136
- await updateTerraformStatusBar ( textEditor . document . uri ) ;
137
- } ) ,
128
+ // vscode.window.onDidChangeVisibleTextEditors(async () => {
129
+ // const textEditor = getActiveTextEditor();
130
+ // if (textEditor === undefined) {
131
+ // return;
132
+ // }
133
+ // if (textEditor.document === undefined) {
134
+ // return;
135
+ // }
136
+ // await updateTerraformStatusBar(textEditor.document.uri);
137
+ // }),
138
138
vscode . window . registerTreeDataProvider ( 'terraform.modules' , new ModuleProvider ( context , clientHandler ) ) ,
139
139
) ;
140
140
141
- if ( enabled ( ) ) {
141
+ // if (enabled()) {
142
+ // try {
143
+ // vscode.commands.executeCommand('setContext', 'terraform.showModuleView', true);
144
+ // const ds = await updateLanguageServer(manifest.version, clientHandler, lsPath);
145
+ // context.subscriptions.push(...ds);
146
+ // } catch (error) {
147
+ // reporter.sendTelemetryException(error);
148
+ // }
149
+ // }
150
+
151
+ if ( config ( 'terraform' ) . get < boolean > ( 'languageServer.external' ) ) {
142
152
try {
153
+ vscode . commands . executeCommand ( 'setContext' , 'terraform.showModuleView' , true ) ;
143
154
await updateLanguageServer ( manifest . version , clientHandler , lsPath ) ;
144
155
vscode . commands . executeCommand ( 'setContext' , 'terraform.showModuleView' , true ) ;
156
+
157
+ ( await clientHandler . getClient ( ) ) . client . onReady ( ) . then ( ( ) => {
158
+ context . subscriptions . push (
159
+ vscode . window . onDidChangeVisibleTextEditors ( async ( ) => {
160
+ // can't register this until client is ready, otherwise we can't
161
+ // know if command is supported
162
+ const textEditor = getActiveTextEditor ( ) ;
163
+ if ( textEditor === undefined ) {
164
+ return ;
165
+ }
166
+
167
+ await updateTerraformStatusBar ( textEditor . document . uri ) ;
168
+ } ) ,
169
+ ) ;
170
+ } ) ;
145
171
} catch ( error ) {
146
172
reporter . sendTelemetryException ( error ) ;
147
173
}
0 commit comments