Skip to content

Commit 69f59d9

Browse files
committed
does this work
1 parent a538cc3 commit 69f59d9

File tree

3 files changed

+52
-14
lines changed

3 files changed

+52
-14
lines changed

src/clientHandler.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ export class ClientHandler {
5959
}
6060

6161
public async stopClients(): Promise<void> {
62+
if (this.tfClient === undefined || this.tfClient.client === undefined) {
63+
return;
64+
}
65+
6266
return this.tfClient.client
6367
.stop()
6468
.then(() => {
@@ -144,7 +148,8 @@ export class ClientHandler {
144148
return this.tfClient;
145149
}
146150

147-
public clientSupportsCommand(cmdName: string): boolean {
151+
public async clientSupportsCommand(cmdName: string): Promise<boolean> {
152+
await this.tfClient.client.onReady();
148153
return this.supportedCommands.includes(cmdName);
149154
}
150155
}

src/extension.ts

+37-11
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,49 @@ export async function activate(context: vscode.ExtensionContext): Promise<Terraf
125125
await clientHandler.startClients();
126126
}
127127
}),
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+
// }),
138138
vscode.window.registerTreeDataProvider('terraform.modules', new ModuleProvider(context, clientHandler)),
139139
);
140140

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')) {
142152
try {
153+
vscode.commands.executeCommand('setContext', 'terraform.showModuleView', true);
143154
await updateLanguageServer(manifest.version, clientHandler, lsPath);
144155
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+
});
145171
} catch (error) {
146172
reporter.sendTelemetryException(error);
147173
}

src/test/integration/workspaces.test.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,17 @@ suite('moduleCallers', () => {
2020

2121
assert.ok(ext.isActive);
2222

23-
const client = await ext.exports.handler.getClient();
23+
const api = ext.exports;
24+
assert.ok(api.handler);
25+
assert.ok(api.moduleCallers);
26+
27+
const client = await api.handler.getClient();
28+
assert.ok(client);
2429

2530
const moduleUri = Utils.dirname(documentUri).toString();
26-
const response = await ext.exports.moduleCallers(client, moduleUri);
31+
const response = await api.moduleCallers(client, moduleUri);
32+
assert.ok(response);
33+
2734
assert.strictEqual(response.moduleCallers.length, 1);
2835
assert.strictEqual(response.moduleCallers[0].uri, vscode.Uri.file(testFolderPath).toString(true));
2936
})

0 commit comments

Comments
 (0)