1515-- of the license. --
1616----------------------------------------------------------------------------*/
1717
18+ import * as process from 'process' ;
1819import * as vscode from 'vscode' ;
1920import {
2021 Disposable ,
@@ -25,14 +26,10 @@ import {
2526 ServerOptions ,
2627 SymbolKind ,
2728} 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' ;
3329import { 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' ;
3633
3734export let contextClients : ContextClients ;
3835export let mainLogChannel : vscode . OutputChannel ;
@@ -181,29 +178,11 @@ function createClient(
181178 // Retrieve the user's custom environment variables if specified in their
182179 // settings/workspace: we'll then launch any child process with this custom
183180 // 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 ( ) ;
199182
200183 if ( custom_env ) {
201184 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 ] ;
207186 process . env [ var_name ] = var_value ;
208187 }
209188 }
@@ -243,42 +222,44 @@ function createClient(
243222async function addSupbrogramBox ( ) {
244223 const activeEditor = vscode . window . activeTextEditor ;
245224
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+ }
279260 }
280261 }
281- } ) ;
262+ ) ;
282263}
283264
284265type ALSSourceDirDescription = {
0 commit comments