@@ -146,29 +146,32 @@ export function deactivate(): Promise<void> {
146
146
147
147
async function updateTerraformStatusBar ( documentUri : vscode . Uri ) {
148
148
const initSupported = clientHandler . clientSupportsCommand ( 'terraform-ls.terraform.init' ) ;
149
- if ( initSupported ) {
150
- const client = clientHandler . getClient ( ) ;
151
- const moduleUri = Utils . dirname ( documentUri ) ;
149
+ if ( ! initSupported ) {
150
+ return ;
151
+ }
152
152
153
- if ( client ) {
154
- try {
155
- const response = await moduleCallers ( client , moduleUri . toString ( ) ) ;
156
- if ( response . moduleCallers . length === 0 ) {
157
- const dirName = Utils . basename ( moduleUri ) ;
158
- terraformStatus . text = `$(refresh) ${ dirName } ` ;
159
- terraformStatus . color = new vscode . ThemeColor ( 'statusBar.foreground' ) ;
160
- terraformStatus . tooltip = `Click to run terraform init` ;
161
- terraformStatus . command = 'terraform.initCurrent' ;
162
- terraformStatus . show ( ) ;
163
- } else {
164
- terraformStatus . hide ( ) ;
165
- }
166
- } catch ( err ) {
167
- vscode . window . showErrorMessage ( err ) ;
168
- reporter . sendTelemetryException ( err ) ;
169
- terraformStatus . hide ( ) ;
170
- }
153
+ const client = clientHandler . getClient ( ) ;
154
+ if ( ! client ) {
155
+ return ;
156
+ }
157
+
158
+ try {
159
+ const moduleUri = Utils . dirname ( documentUri ) ;
160
+ const response = await moduleCallers ( client , moduleUri . toString ( ) ) ;
161
+ if ( response . moduleCallers . length === 0 ) {
162
+ const dirName = Utils . basename ( moduleUri ) ;
163
+ terraformStatus . text = `$(refresh) ${ dirName } ` ;
164
+ terraformStatus . color = new vscode . ThemeColor ( 'statusBar.foreground' ) ;
165
+ terraformStatus . tooltip = `Click to run terraform init` ;
166
+ terraformStatus . command = 'terraform.initCurrent' ;
167
+ terraformStatus . show ( ) ;
168
+ } else {
169
+ terraformStatus . hide ( ) ;
171
170
}
171
+ } catch ( err ) {
172
+ vscode . window . showErrorMessage ( err ) ;
173
+ reporter . sendTelemetryException ( err ) ;
174
+ terraformStatus . hide ( ) ;
172
175
}
173
176
}
174
177
0 commit comments