@@ -4,6 +4,7 @@ import { createClient } from './clients';
44import GnatTaskProvider from './gnatTaskProvider' ;
55import GprTaskProvider from './gprTaskProvider' ;
66import { 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