Skip to content

Commit 707cba4

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 6304fe0 commit 707cba4

4 files changed

Lines changed: 12 additions & 4 deletions

File tree

extensions/ql-vscode/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Avoid displaying an error when removing orphaned databases and the storage folder does not exist. [#748](https://github.com/github/vscode-codeql/pull/748)
66
- Add better error messages when AST Viewer is unable to create an AST. [#753](https://github.com/github/vscode-codeql/pull/753)
77
- Cache AST viewing operations so that subsequent calls to view the AST of a single file will be extremely fast. [#753](https://github.com/github/vscode-codeql/pull/753)
8+
- Ensure CodeQL version in status bar updates correctly when version changes. [#754](https://github.com/github/vscode-codeql/pull/754)
89

910
## 1.4.2 - 2 February 2021
1011

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)