Skip to content

Commit 35bb16a

Browse files
committed
Fix issues with dynamic updating of the version status bar item
1. Wait a few seconds before updating the status bar after a version change. 2. Ensure we are watching the correct configuration items for changes. 3. Ensure the cli version is refreshed correctly.
1 parent 57d856f commit 35bb16a

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

extensions/ql-vscode/src/cli.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ export class CodeQLCliServer implements Disposable {
162162
if (this.distributionProvider.onDidChangeDistribution) {
163163
this.distributionProvider.onDidChangeDistribution(() => {
164164
this.restartCliServer();
165+
this._version = undefined;
165166
});
166167
}
167168
if (this.cliConfig.onDidChangeConfiguration) {

extensions/ql-vscode/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const GLOBAL_ENABLE_TELEMETRY = new Setting('enableTelemetry', GLOBAL_TEL
5050

5151
// Distribution configuration
5252
const DISTRIBUTION_SETTING = new Setting('cli', ROOT_SETTING);
53-
const CUSTOM_CODEQL_PATH_SETTING = new Setting('executablePath', DISTRIBUTION_SETTING);
53+
export const CUSTOM_CODEQL_PATH_SETTING = new Setting('executablePath', DISTRIBUTION_SETTING);
5454
const INCLUDE_PRERELEASE_SETTING = new Setting('includePrerelease', DISTRIBUTION_SETTING);
5555
const PERSONAL_ACCESS_TOKEN_SETTING = new Setting('personalAccessToken', DISTRIBUTION_SETTING);
5656
const QUERY_HISTORY_SETTING = new Setting('queryHistory', ROOT_SETTING);

extensions/ql-vscode/src/status-bar.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ConfigurationChangeEvent, StatusBarAlignment, StatusBarItem, window, workspace } from 'vscode';
22
import { CodeQLCliServer } from './cli';
3-
import { CANARY_FEATURES, DistributionConfigListener } from './config';
3+
import { CANARY_FEATURES, CUSTOM_CODEQL_PATH_SETTING, DistributionConfigListener } from './config';
44
import { DisposableObject } from './pure/disposable-object';
55

66
/**
@@ -24,8 +24,14 @@ export class CodeQlStatusBarHandler extends DisposableObject {
2424
}
2525

2626
private handleDidChangeConfiguration(e: ConfigurationChangeEvent) {
27-
if (e.affectsConfiguration(CANARY_FEATURES.qualifiedName)) {
28-
this.updateStatusItem();
27+
if (
28+
e.affectsConfiguration(CANARY_FEATURES.qualifiedName) ||
29+
e.affectsConfiguration(CUSTOM_CODEQL_PATH_SETTING.qualifiedName)
30+
) {
31+
// Wait a few seconds before updating the status item.
32+
// This avoids a race condition where the cli's version
33+
// is not updated before the status bar is refreshed.
34+
setTimeout(() => this.updateStatusItem(), 3000);
2935
}
3036
}
3137

0 commit comments

Comments
 (0)