@@ -4,6 +4,7 @@ import { createClient } from './clients';
4
4
import GnatTaskProvider from './gnatTaskProvider' ;
5
5
import GprTaskProvider from './gprTaskProvider' ;
6
6
import { registerTaskProviders } from './taskProviders' ;
7
+ import { getCustomEnvSettingName } from './helpers' ;
7
8
8
9
/**
9
10
* This class encapsulates all state that should be maintained throughout the
@@ -71,6 +72,26 @@ export class ExtensionState {
71
72
this . registeredTaskProviders = [ ] ;
72
73
} ;
73
74
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
+
74
95
// React to changes in configuration to recompute predefined tasks if the user
75
96
// changes scenario variables' values.
76
97
public configChanged = ( e : vscode . ConfigurationChangeEvent ) => {
@@ -81,5 +102,14 @@ export class ExtensionState {
81
102
this . unregisterTaskProviders ( ) ;
82
103
this . registerTaskProviders ( ) ;
83
104
}
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
+ }
84
114
} ;
85
115
}
0 commit comments