Skip to content

Commit 7979f1e

Browse files
Show a popup to reload the window on environment changes
A popup is now shown when the user changes VS Code settings that affect the environment. This popup asks the user if he wants to reload the VS Code window to make the Ada extension take into account the newly set environment. For eng/ide/ada_language_server#1218
1 parent 916972f commit 7979f1e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

integration/vscode/ada/src/ExtensionState.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { createClient } from './clients';
44
import GnatTaskProvider from './gnatTaskProvider';
55
import GprTaskProvider from './gprTaskProvider';
66
import { registerTaskProviders } from './taskProviders';
7+
import { getCustomEnvSettingName } from './helpers';
78

89
/**
910
* This class encapsulates all state that should be maintained throughout the
@@ -71,6 +72,26 @@ export class ExtensionState {
7172
this.registeredTaskProviders = [];
7273
};
7374

75+
/**
76+
* Show a popup asking the user to reload the VS Code window after
77+
* changes made in the VS Code environment settings
78+
* (e.g: terminal.integrated.env.linux).
79+
*/
80+
public showReloadWindowPopup = async () => {
81+
const selection = await vscode.window.showWarningMessage(
82+
`The workspace environment has changed: the VS Code window needs
83+
to be reloaded in order for the Ada Language Server to take the
84+
new environment into account.
85+
Do you want to reload the VS Code window?`,
86+
'Reload Window'
87+
);
88+
89+
// Reload the VS Code window if the user selected 'Yes'
90+
if (selection == 'Reload Window') {
91+
void vscode.commands.executeCommand('workbench.action.reloadWindow');
92+
}
93+
};
94+
7495
// React to changes in configuration to recompute predefined tasks if the user
7596
// changes scenario variables' values.
7697
public configChanged = (e: vscode.ConfigurationChangeEvent) => {
@@ -81,5 +102,14 @@ export class ExtensionState {
81102
this.unregisterTaskProviders();
82103
this.registerTaskProviders();
83104
}
105+
106+
// React to changes made in the environment variables, showing
107+
// a popup to reload the VS Code window and thus restart the
108+
// Ada extension.
109+
const env_config_name = getCustomEnvSettingName();
110+
111+
if (e.affectsConfiguration(env_config_name)) {
112+
void this.showReloadWindowPopup();
113+
}
84114
};
85115
}

0 commit comments

Comments
 (0)