Skip to content

Commit

Permalink
Merge pull request #195416 from microsoft/tyriar/184009
Browse files Browse the repository at this point in the history
Defer applying env vars until first prompt
  • Loading branch information
Tyriar authored Oct 12, 2023
2 parents 4afb8f7 + e01c0a2 commit 7f3049c
Showing 1 changed file with 31 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,37 @@ if status --is-login; and set -q VSCODE_PATH_PREFIX
end
set -e VSCODE_PATH_PREFIX

# Apply EnvironmentVariableCollections if needed
if test -n "$VSCODE_ENV_REPLACE"
set ITEMS (string split : $VSCODE_ENV_REPLACE)
for B in $ITEMS
set split (string split = $B)
set -gx "$split[1]" (echo -e "$split[2]")
set -g __vsc_applied_env_vars 0
function __vsc_apply_env_vars
if test $__vsc_applied_env_vars -eq 1;
return
end
set -e VSCODE_ENV_REPLACE
end
if test -n "$VSCODE_ENV_PREPEND"
set ITEMS (string split : $VSCODE_ENV_PREPEND)
for B in $ITEMS
set split (string split = $B)
set -gx "$split[1]" (echo -e "$split[2]")"$$split[1]" # avoid -p as it adds a space
set -l __vsc_applied_env_vars 1
# Apply EnvironmentVariableCollections if needed
if test -n "$VSCODE_ENV_REPLACE"
set ITEMS (string split : $VSCODE_ENV_REPLACE)
for B in $ITEMS
set split (string split = $B)
set -gx "$split[1]" (echo -e "$split[2]")
end
set -e VSCODE_ENV_REPLACE
end
set -e VSCODE_ENV_PREPEND
end
if test -n "$VSCODE_ENV_APPEND"
set ITEMS (string split : $VSCODE_ENV_APPEND)
for B in $ITEMS
set split (string split = $B)
set -gx "$split[1]" "$$split[1]"(echo -e "$split[2]") # avoid -a as it adds a space
if test -n "$VSCODE_ENV_PREPEND"
set ITEMS (string split : $VSCODE_ENV_PREPEND)
for B in $ITEMS
set split (string split = $B)
set -gx "$split[1]" (echo -e "$split[2]")"$$split[1]" # avoid -p as it adds a space
end
set -e VSCODE_ENV_PREPEND
end
if test -n "$VSCODE_ENV_APPEND"
set ITEMS (string split : $VSCODE_ENV_APPEND)
for B in $ITEMS
set split (string split = $B)
set -gx "$split[1]" "$$split[1]"(echo -e "$split[2]") # avoid -a as it adds a space
end
set -e VSCODE_ENV_APPEND
end
set -e VSCODE_ENV_APPEND
end

# Handle the shell integration nonce
Expand Down Expand Up @@ -140,6 +147,9 @@ end
# Sent at the start of the prompt.
# Marks the beginning of the prompt (and, implicitly, a new line).
function __vsc_fish_prompt_start
# Applying environment variables is deferred to after config.fish has been
# evaluated
__vsc_apply_env_vars
__vsc_esc A
end

Expand Down

0 comments on commit 7f3049c

Please sign in to comment.