diff --git a/Extension/CHANGELOG.md b/Extension/CHANGELOG.md index 36915cfa6a..513fc9dfa7 100644 --- a/Extension/CHANGELOG.md +++ b/Extension/CHANGELOG.md @@ -1,5 +1,8 @@ # C/C++ for Visual Studio Code Change Log +## Version 1.4.1: June 8, 2021 +* Fix the configuration UI sometimes not populating initially with VS Code 1.56 or later. [#7641](https://github.com/microsoft/vscode-cpptools/issues/7641) + ## Version 1.4.0: May 27, 2021 ### New Features * Add a C++ walkthrough to the "Getting Started" page. [#7273](https://github.com/microsoft/vscode-cpptools/issues/7273) diff --git a/Extension/package.json b/Extension/package.json index 5082264a4d..3a1343468c 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -2,7 +2,7 @@ "name": "cpptools", "displayName": "C/C++", "description": "C/C++ IntelliSense, debugging, and code browsing.", - "version": "1.4.0-main", + "version": "1.4.1-main", "publisher": "ms-vscode", "icon": "LanguageCCPP_color_128x.png", "readme": "README.md", diff --git a/Extension/src/LanguageServer/configurations.ts b/Extension/src/LanguageServer/configurations.ts index ad250170ef..106def41e4 100644 --- a/Extension/src/LanguageServer/configurations.ts +++ b/Extension/src/LanguageServer/configurations.ts @@ -975,7 +975,11 @@ export class CppProperties { const settings: CppSettings = new CppSettings(this.rootUri); this.settingsPanel = new SettingsPanel(); this.settingsPanel.setKnownCompilers(this.knownCompilers, settings.preferredPathSeparator); - this.settingsPanel.SettingsPanelActivated(() => this.onSettingsPanelActivated()); + this.settingsPanel.SettingsPanelActivated(() => { + if (this.settingsPanel?.initialized) { + this.onSettingsPanelActivated(); + } + }); this.settingsPanel.ConfigValuesChanged(() => this.saveConfigurationUI()); this.settingsPanel.ConfigSelectionChanged(() => this.onConfigSelectionChanged()); this.settingsPanel.AddConfigRequested((e) => this.onAddConfigRequested(e)); @@ -1025,14 +1029,9 @@ export class CppProperties { if (this.settingsPanel.selectedConfigIndex >= this.configurationJson.configurations.length) { this.settingsPanel.selectedConfigIndex = this.CurrentConfigurationIndex; } - setTimeout(() => { - if (this.settingsPanel && this.configurationJson) { - this.settingsPanel.updateConfigUI(configNames, - this.configurationJson.configurations[this.settingsPanel.selectedConfigIndex], - this.getErrorsForConfigUI(this.settingsPanel.selectedConfigIndex)); - } - }, - 500); // Need some delay or the UI can randomly be blank, particularly in the remote scenario. + this.settingsPanel.updateConfigUI(configNames, + this.configurationJson.configurations[this.settingsPanel.selectedConfigIndex], + this.getErrorsForConfigUI(this.settingsPanel.selectedConfigIndex)); } else { // Parse failed, open json file vscode.workspace.openTextDocument(this.propertiesFile); diff --git a/Extension/src/LanguageServer/settingsPanel.ts b/Extension/src/LanguageServer/settingsPanel.ts index c3338781ae..1dc68e5817 100644 --- a/Extension/src/LanguageServer/settingsPanel.ts +++ b/Extension/src/LanguageServer/settingsPanel.ts @@ -73,6 +73,12 @@ export class SettingsPanel { private static readonly viewType: string = 'settingsPanel'; private static readonly title: string = 'C/C++ Configurations'; + // Used to workaround a VS Code 1.56 regression in which webViewPanel.onDidChangeViewState + // gets called before the SettingsApp constructor is finished running. + // It repros with a higher probability in cases that cause a slower load, + // such as after switching to a Chinese language pack or in the remote scenario. + public initialized: boolean = false; + constructor() { this.disposable = vscode.Disposable.from( this.settingsPanelActivated, @@ -91,6 +97,8 @@ export class SettingsPanel { return; } + this.initialized = false; + // Create new panel this.panel = vscode.window.createWebviewPanel( SettingsPanel.viewType, @@ -211,7 +219,7 @@ export class SettingsPanel { private updateWebview(configSelection: string[], configuration: config.Configuration, errors: config.ConfigurationErrors | null): void { this.configValues = {...configuration}; // Copy configuration values this.isIntelliSenseModeDefined = (this.configValues.intelliSenseMode !== undefined); - if (this.panel) { + if (this.panel && this.initialized) { this.panel.webview.postMessage({ command: 'setKnownCompilers', compilers: this.compilerPaths }); this.panel.webview.postMessage({ command: 'updateConfigSelection', selections: configSelection, selectedIndex: this.configIndexSelected }); this.panel.webview.postMessage({ command: 'updateConfig', config: this.configValues }); @@ -250,6 +258,10 @@ export class SettingsPanel { case 'knownCompilerSelect': this.knownCompilerSelect(); break; + case "initialized": + this.initialized = true; + this.settingsPanelActivated.fire(); + break; } } diff --git a/Extension/ui/settings.ts b/Extension/ui/settings.ts index 8451859da1..e184af6097 100644 --- a/Extension/ui/settings.ts +++ b/Extension/ui/settings.ts @@ -81,6 +81,9 @@ class SettingsApp { document.getElementById(elementId.advancedSection).style.display = advancedShown ? "block" : "none"; document.getElementById(elementId.showAdvanced).classList.toggle(advancedShown ? "collapse" : "expand", true); document.getElementById(elementId.showAdvanced).addEventListener("click", this.onShowAdvanced.bind(this)); + this.vsCodeApi.postMessage({ + command: "initialized" + }); } private addEventsToInputValues(): void {