Skip to content

Commit

Permalink
Conditionally activate the Module View Provider (#792)
Browse files Browse the repository at this point in the history
This detects whether the currently installed Language Server supports the module calls command before calling the Language Server command. This prevents the provider from throwing an error with a LS that doesn't have the command.
  • Loading branch information
jpogran authored Sep 24, 2021
1 parent b1c8f9b commit 99356fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
"viewsWelcome": [
{
"view": "terraform.modules",
"contents": "The active editor cannot provide information about installed modules. [Learn more about modules](https://www.terraform.io/docs/language/modules/develop/index.html) You may need to run 'terraform get'"
"contents": "The active editor cannot provide information about installed modules. [Learn more about modules](https://www.terraform.io/docs/language/modules/develop/index.html) You may need to run 'terraform get' or update your language server version."
}
]
},
Expand Down
8 changes: 8 additions & 0 deletions src/providers/moduleProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ export class ModuleProvider implements vscode.TreeDataProvider<ModuleCall> {
const handler = this.handler.getClient(editor);

return await handler.client.onReady().then(async () => {
const moduleCallsSupported = this.handler.clientSupportsCommand(
`${handler.commandPrefix}.terraform-ls.module.calls`,
editor,
);
if (!moduleCallsSupported) {
return Promise.resolve([]);
}

const params: ExecuteCommandParams = {
command: `${handler.commandPrefix}.terraform-ls.module.calls`,
arguments: [`uri=${documentURI}`],
Expand Down

0 comments on commit 99356fe

Please sign in to comment.