15
15
-- of the license. --
16
16
----------------------------------------------------------------------------*/
17
17
18
+ import * as process from 'process' ;
18
19
import * as vscode from 'vscode' ;
19
20
import {
20
21
Disposable ,
@@ -25,14 +26,10 @@ import {
25
26
ServerOptions ,
26
27
SymbolKind ,
27
28
} from 'vscode-languageclient/node' ;
28
- import { platform } from 'os' ;
29
- import * as process from 'process' ;
30
- import GnatTaskProvider from './gnatTaskProvider' ;
31
- import GprTaskProvider from './gprTaskProvider' ;
32
- import { getEnclosingSymbol } from './gnatTaskProvider' ;
33
29
import { alsCommandExecutor } from './alsExecuteCommand' ;
34
- import { ALSClientFeatures } from './alsClientFeatures' ;
35
- import { substituteVariables } from './helpers' ;
30
+ import GnatTaskProvider , { getEnclosingSymbol } from './gnatTaskProvider' ;
31
+ import GprTaskProvider from './gprTaskProvider' ;
32
+ import { getEvaluatedCustomEnv } from './helpers' ;
36
33
37
34
export let contextClients : ContextClients ;
38
35
export let mainLogChannel : vscode . OutputChannel ;
@@ -181,29 +178,11 @@ function createClient(
181
178
// Retrieve the user's custom environment variables if specified in their
182
179
// settings/workspace: we'll then launch any child process with this custom
183
180
// environment
184
- const user_platform = platform ( ) ;
185
- let env_config_name = 'terminal.integrated.env.linux' ;
186
-
187
- switch ( user_platform ) {
188
- case 'darwin' :
189
- env_config_name = 'terminal.integrated.env.osx' ;
190
- break ;
191
- case 'win32' :
192
- env_config_name = 'terminal.integrated.env.windows' ;
193
- break ;
194
- default :
195
- env_config_name = 'terminal.integrated.env.linux' ;
196
- }
197
-
198
- const custom_env = vscode . workspace . getConfiguration ( ) . get < [ string ] > ( env_config_name ) ;
181
+ const custom_env = getEvaluatedCustomEnv ( ) ;
199
182
200
183
if ( custom_env ) {
201
184
for ( const var_name in custom_env ) {
202
- let var_value : string = custom_env [ var_name ] ;
203
-
204
- // Substitute VS Code variable references that might be present
205
- // in the JSON settings configuration (e.g: "PATH": "${workspaceFolder}/obj")
206
- var_value = var_value . replace ( / ( \$ \{ .* \} ) / , substituteVariables ) ;
185
+ const var_value : string = custom_env [ var_name ] ;
207
186
process . env [ var_name ] = var_value ;
208
187
}
209
188
}
@@ -243,42 +222,44 @@ function createClient(
243
222
async function addSupbrogramBox ( ) {
244
223
const activeEditor = vscode . window . activeTextEditor ;
245
224
246
- await getEnclosingSymbol (
247
- activeEditor , [ SymbolKind . Function , SymbolKind . Module ] ) . then ( async ( symbol ) => {
248
- if ( symbol !== null ) {
249
- const name : string = symbol . name ?? '' ;
250
- const insertPos = new vscode . Position ( symbol . range . start . line , 0 ) ;
251
- const indentationRange = new vscode . Range ( insertPos , symbol . range . start ) ;
252
- const indentation : string = activeEditor ?. document . getText ( indentationRange ) ?? '' ;
253
- const eol : string = activeEditor ?. document . eol == vscode . EndOfLine . CRLF ? '\r\n' : '\n' ;
254
-
255
- // Generate the subprogram box after retrieving the indentation of the line of
256
- // the subprogram's body declaration.
257
- const text : string =
258
- indentation +
259
- '---' +
260
- '-' . repeat ( name . length ) +
261
- '---' +
262
- eol +
263
- indentation +
264
- '-- ' +
265
- name +
266
- ' --' +
267
- eol +
268
- indentation +
269
- '---' +
270
- '-' . repeat ( name . length ) +
271
- '---' +
272
- eol +
273
- eol ;
274
-
275
- if ( activeEditor ) {
276
- await activeEditor . edit ( ( editBuilder ) => {
277
- editBuilder . insert ( insertPos , text ) ;
278
- } ) ;
225
+ await getEnclosingSymbol ( activeEditor , [ SymbolKind . Function , SymbolKind . Module ] ) . then (
226
+ async ( symbol ) => {
227
+ if ( symbol !== null ) {
228
+ const name : string = symbol . name ?? '' ;
229
+ const insertPos = new vscode . Position ( symbol . range . start . line , 0 ) ;
230
+ const indentationRange = new vscode . Range ( insertPos , symbol . range . start ) ;
231
+ const indentation : string = activeEditor ?. document . getText ( indentationRange ) ?? '' ;
232
+ const eol : string =
233
+ activeEditor ?. document . eol == vscode . EndOfLine . CRLF ? '\r\n' : '\n' ;
234
+
235
+ // Generate the subprogram box after retrieving the indentation of the line of
236
+ // the subprogram's body declaration.
237
+ const text : string =
238
+ indentation +
239
+ '---' +
240
+ '-' . repeat ( name . length ) +
241
+ '---' +
242
+ eol +
243
+ indentation +
244
+ '-- ' +
245
+ name +
246
+ ' --' +
247
+ eol +
248
+ indentation +
249
+ '---' +
250
+ '-' . repeat ( name . length ) +
251
+ '---' +
252
+ eol +
253
+ eol ;
254
+
255
+ if ( activeEditor ) {
256
+ await activeEditor . edit ( ( editBuilder ) => {
257
+ editBuilder . insert ( insertPos , text ) ;
258
+ } ) ;
259
+ }
279
260
}
280
261
}
281
- } ) ;
262
+ ) ;
282
263
}
283
264
284
265
type ALSSourceDirDescription = {
0 commit comments