src/vs/workbench/contrib/terminal/common/terminalEnvironment.ts

443 LOC · 327 covered · 116 uncovered · 90 ranges · 52 concepts · 42 introducers · 44 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the filesrc/vs/base/common/processes.ts · 153 LOCcommon/processes.tsterminalEnvironment.ts ×1 · 2 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.test|title=Workbench - TerminalEnvironment getWorkspaceForTerminal should resolve workspace folder from cwd, not last active workspace|occurrence=1 · 0 introduced LOCterminalEnvironment.test…terminalEnvironment.ts ×1 · 2 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.test|title=Workbench - TerminalEnvironment getWorkspaceForTerminal should fall back to last active workspace when cwd is not in any workspace folder|occurrence=1 · 0 introduced LOCterminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Linux frontend, Linux backend Bash|occurrence=1, terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Windows frontend, Linux backend Bash|occurrence=1 · 0 introduced LOCterminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Linux frontend, Linux backend Fish|occurrence=1, terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Windows frontend, Linux backend Fish|occurrence=1 · 0 introduced LOCterminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment getWorkspaceForTerminal should fall back to last active workspace when cwd is undefined|occurrence=1 · 0 introduced LOCterminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment getCwd should fall back for relative a custom cwd that doesn't have a workspace|occurrence=1 · 0 introduced LOCterminalEnvironment.test…terminalEnvironment.ts ×1 · 1 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×1 · 2 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×4 · 6 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×7 · 54 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×1 · 2 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Linux frontend, Linux backend Zsh|occurrence=1, terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Windows frontend, Linux backend Zsh|occurrence=1 · 0 introduced LOCterminalEnvironment.test…terminalEnvironment.ts ×1 · 3 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×1 · 2 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×4 · 19 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×1 · 2 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.test|title=Workbench - TerminalEnvironment addTerminalEnvironmentKeys should set expected variables|occurrence=1 · 0 introduced LOCterminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment addTerminalEnvironmentKeys should use language variant for LANG that is provided in locale|occurrence=1 · 0 introduced LOCterminalEnvironment.test…terminalEnvironment.ts ×2 · 3 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×1 · 1 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.test|title=Workbench - TerminalEnvironment addTerminalEnvironmentKeys should override existing LANG|occurrence=1, terminalEnvironment.test|title=Workbench - TerminalEnvironment addTerminalEnvironmentKeys should fallback to en_US when no locale is provided|occurrence=1, +1 · 0 introduced LOCterminalEnvironment.test…terminalEnvironment.ts ×1 · 1 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×1 · 2 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×2 · 5 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×1 · 3 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×2 · 4 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×4 · 8 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×1 · 4 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×1 · 2 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×6 · 19 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×1 · 1 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×1 · 5 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×1 · 1 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×1 · 61 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×1 · 3 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×2 · 5 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×2 · 2 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×1 · 3 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×3 · 5 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×3 · 4 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×4 · 10 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×1 · 3 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×1 · 2 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×3 · 5 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×1 · 3 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×1 · 2 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×1 · 1 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×1 · 1 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×1 · 3 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.ts ×15 · 62 introduced LOCterminalEnvironment.ts ×…terminalEnvironment.test|title=Workbench - TerminalEnvironment addTerminalEnvironmentKeys should fallback to en_US when an invalid locale is provided|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment addTerminalEnvironmentKeys should fallback to en_US when an invalid locale is provided|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment addTerminalEnvironmentKeys should fallback to en_US when no locale is provided|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment addTerminalEnvironmentKeys should fallback to en_US when no locale is provided|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment addTerminalEnvironmentKeys should override existing LANG|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment addTerminalEnvironmentKeys should override existing LANG|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment addTerminalEnvironmentKeys should set expected variables|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment addTerminalEnvironmentKeys should set expected variables|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment addTerminalEnvironmentKeys should use language variant for LANG that is provided in locale|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment addTerminalEnvironmentKeys should use language variant for LANG that is provided in locale|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment createTerminalEnvironment should retain variables equal to the empty string|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment createTerminalEnvironment should retain variables equal to the empty string|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment formatUriForShellDisplay Bash Non-Windows frontend|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment formatUriForShellDisplay Bash Non-Windows frontend|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment formatUriForShellDisplay Bash Windows frontend|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment formatUriForShellDisplay Bash Windows frontend|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment formatUriForShellDisplay GitBash|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment formatUriForShellDisplay GitBash|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment formatUriForShellDisplay PowerShell Non-Windows frontend|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment formatUriForShellDisplay PowerShell Non-Windows frontend|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment formatUriForShellDisplay PowerShell Windows frontend|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment formatUriForShellDisplay PowerShell Windows frontend|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment formatUriForShellDisplay Wsl|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment formatUriForShellDisplay Wsl|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment getCwd should default to userHome for an empty workspace|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment getCwd should default to userHome for an empty workspace|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment getCwd should fall back for relative a custom cwd that doesn't have a workspace|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment getCwd should fall back for relative a custom cwd that doesn't have a workspace|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment getCwd should ignore custom cwd when told to ignore|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment getCwd should ignore custom cwd when told to ignore|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment getCwd should normalize a relative custom cwd against the workspace path|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment getCwd should normalize a relative custom cwd against the workspace path|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment getCwd should use an absolute custom cwd as is|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment getCwd should use an absolute custom cwd as is|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment getCwd should use to the workspace if it exists|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment getCwd should use to the workspace if it exists|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment getLangEnvVariable should fallback to default language variants when variant isn't provided|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment getLangEnvVariable should fallback to default language variants when variant isn't provided|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment getLangEnvVariable should fallback to en_US when no locale is provided|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment getLangEnvVariable should fallback to en_US when no locale is provided|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment getLangEnvVariable should set language variant based on full locale|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment getLangEnvVariable should set language variant based on full locale|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment getWorkspaceForTerminal should fall back to last active workspace when cwd is not in any workspace folder|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment getWorkspaceForTerminal should fall back to last active workspace when cwd is not in any workspace folder|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment getWorkspaceForTerminal should fall back to last active workspace when cwd is undefined|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment getWorkspaceForTerminal should fall back to last active workspace when cwd is undefined|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment getWorkspaceForTerminal should resolve workspace folder from cwd, not last active workspace|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment getWorkspaceForTerminal should resolve workspace folder from cwd, not last active workspace|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment getWorkspaceForTerminal should return undefined when cwd and history are both unavailable|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment getWorkspaceForTerminal should return undefined when cwd and history are both unavailable|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment mergeEnvironments null values should delete keys from the parent env|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment mergeEnvironments null values should delete keys from the parent env|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment mergeEnvironments should add keys|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment mergeEnvironments should add keys|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Linux frontend, Linux backend Bash|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Linux frontend, Linux backend Bash|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Linux frontend, Linux backend Fish|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Linux frontend, Linux backend Fish|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Linux frontend, Linux backend Zsh|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Linux frontend, Linux backend Zsh|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Linux frontend, Windows backend Command Prompt|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Linux frontend, Windows backend Command Prompt|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Linux frontend, Windows backend Git Bash|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Linux frontend, Windows backend Git Bash|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Linux frontend, Windows backend PowerShell|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Linux frontend, Windows backend PowerShell|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Linux frontend, Windows backend WSL|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Linux frontend, Windows backend WSL|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Windows frontend, Linux backend Bash|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Windows frontend, Linux backend Bash|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Windows frontend, Linux backend Fish|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Windows frontend, Linux backend Fish|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Windows frontend, Linux backend Zsh|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Windows frontend, Linux backend Zsh|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Windows frontend, Windows backend Command Prompt|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Windows frontend, Windows backend Command Prompt|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Windows frontend, Windows backend Git Bash|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Windows frontend, Windows backend Git Bash|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Windows frontend, Windows backend PowerShell|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Windows frontend, Windows backend PowerShell|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Windows frontend, Windows backend WSL|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment preparePathForShell Windows frontend, Windows backend WSL|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment shouldSetLangEnvVariable auto|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment shouldSetLangEnvVariable auto|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment shouldSetLangEnvVariable off|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment shouldSetLangEnvVariable off|occurrence=1terminalEnvironment.test…terminalEnvironment.test|title=Workbench - TerminalEnvironment shouldSetLangEnvVariable on|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/terminal/test/common/terminalEnvironment.test|title=Workbench - TerminalEnvironment shouldSetLangEnvVariable on|occurrence=1terminalEnvironment.test…Focused file · src/vs/workbench/contrib/terminal/common/terminalEnvironment.ts · 443 LOCcommon/terminalEnvironme…

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 > /*--------------------------------------------------------------------------------------------- terminalEnvironment.ts ×15
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > /**
7 > * This module contains utility functions related to the environment, cwd and paths.
8 > */
9 >
10 > import * as path from '../../../../base/common/path.js';
11 > import { URI, uriToFsPath } from '../../../../base/common/uri.js';
12 > import { IWorkspaceContextService, IWorkspaceFolder } from '../../../../platform/workspace/common/workspace.js';
13 > import { IConfigurationResolverService } from '../../../services/configurationResolver/common/configurationResolver.js';
14 > import { sanitizeProcessEnvironment } from '../../../../base/common/processes.js';
15 > import { IShellLaunchConfig, ITerminalBackend, ITerminalEnvironment, ShellIntegrationTimeoutOverride, TerminalSettingId, TerminalShellType, WindowsShellType } from '../../../../platform/terminal/common/terminal.js';
16 > import { IProcessEnvironment, isWindows, isMacintosh, language, OperatingSystem } from '../../../../base/common/platform.js';
17 > import { escapeNonWindowsPath, sanitizeCwd } from '../../../../platform/terminal/common/terminalEnvironment.js';
18 > import { isNumber, isString } from '../../../../base/common/types.js';
19 > import { IHistoryService } from '../../../services/history/common/history.js';
20 > import { ILogService } from '../../../../platform/log/common/log.js';
21 > import type { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
22 >
23 > export function mergeEnvironments(parent: IProcessEnvironment, other: ITerminalEnvironment | undefined): void {
24 > if (!other) { terminalEnvironment.ts ×4
26 > }
28 > // On Windows apply the new values ignoring case, while still retaining
29 > // the case of the original key.
30 > if (isWindows) {
31 for (const configKey in other) {
32 let actualKey = configKey;
33 for (const envKey in parent) {
34 if (configKey.toLowerCase() === envKey.toLowerCase()) {
35 actualKey = envKey;
36 break;
37 }
38 }
39 const value = other[configKey];
40 if (value !== undefined) {
41 _mergeEnvironmentValue(parent, actualKey, value);
42 }
43 }
45 > Object.keys(other).forEach((key) => {
46 > const value = other[key]; terminalEnvironment.ts ×4
47 > if (value !== undefined) {
48 > _mergeEnvironmentValue(parent, key, value);
49 > }
51 > }
52 > }
54 > function _mergeEnvironmentValue(env: ITerminalEnvironment, key: string, value: string | null): void { terminalEnvironment.ts ×4
55 > if (isString(value)) {
56 > env[key] = value; terminalEnvironment.ts ×1
58 > delete env[key]; terminalEnvironment.ts ×1
59 > }
62 > export function addTerminalEnvironmentKeys(env: IProcessEnvironment, version: string | undefined, locale: string | undefined, detectLocale: 'auto' | 'off' | 'on'): void {
63 > env['TERM_PROGRAM'] = 'vscode'; terminalEnvironment.ts ×3
64 > if (version) {
65 > env['TERM_PROGRAM_VERSION'] = version; terminalEnvironment.ts ×2
66 > }
67 > if (shouldSetLangEnvVariable(env, detectLocale)) { terminalEnvironment.ts ×3
68 > env['LANG'] = getLangEnvVariable(locale); terminalEnvironment.ts ×2
69 > }
70 > env['COLORTERM'] = 'truecolor'; terminalEnvironment.ts ×3
71 > }
73 > function mergeNonNullKeys(env: IProcessEnvironment, other: ITerminalEnvironment | undefined) { terminalEnvironment.ts ×7
74 > if (!other) {
75 return;
76 }
77 > for (const key of Object.keys(other)) { terminalEnvironment.ts ×7
78 > const value = other[key];
79 > if (value !== undefined && value !== null) {
80 > env[key] = value;
81 > }
82 > }
83 > }
85 async function resolveConfigurationVariables(variableResolver: VariableResolver, env: ITerminalEnvironment): Promise<ITerminalEnvironment> {
86 await Promise.all(Object.entries(env).map(async ([key, value]) => {
87 if (isString(value)) {
88 try {
89 env[key] = await variableResolver(value);
90 } catch (e) {
91 env[key] = value;
92 }
93 }
94 }));
95
96 return env;
97 }
99 > export function shouldSetLangEnvVariable(env: IProcessEnvironment, detectLocale: 'auto' | 'off' | 'on'): boolean {
100 > if (detectLocale === 'on') { terminalEnvironment.ts ×1
101 > return true; terminalEnvironment.ts ×1
102 > }
103 > if (detectLocale === 'auto') { terminalEnvironment.ts ×1
104 > const lang = env['LANG']; terminalEnvironment.ts ×1
105 > return !lang || (lang.search(/\.UTF\-8$/) === -1 && lang.search(/\.utf8$/) === -1 && lang.search(/\.euc.+/) === -1);
106 > }
107 > return false; // 'off' terminalEnvironment.ts ×1
108 > }
110 > export function getLangEnvVariable(locale?: string): string {
111 > const parts = locale ? locale.split('-') : []; terminalEnvironment.ts ×1
112 > const n = parts.length;
113 > if (n === 0) {
114 > // Fallback to en_US if the locale is unknown terminalEnvironment.ts ×1
115 > return 'en_US.UTF-8';
116 > }
117 > if (n === 1) { terminalEnvironment.ts ×3
118 > // The local may only contain the language, not the variant, if this is the case guess the terminalEnvironment.ts ×1
119 > // variant such that it can be used as a valid $LANG variable. The language variant chosen
120 > // is the original and/or most prominent with help from
121 > // https://stackoverflow.com/a/2502675/1156119
122 > // The list of locales was generated by running `locale -a` on macOS
123 > const languageVariants: { [key: string]: string } = {
124 > af: 'ZA',
125 > am: 'ET',
126 > be: 'BY',
127 > bg: 'BG',
128 > ca: 'ES',
129 > cs: 'CZ',
130 > da: 'DK',
131 > // de: 'AT',
132 > // de: 'CH',
133 > de: 'DE',
134 > el: 'GR',
135 > // en: 'AU',
136 > // en: 'CA',
137 > // en: 'GB',
138 > // en: 'IE',
139 > // en: 'NZ',
140 > en: 'US',
141 > es: 'ES',
142 > et: 'EE',
143 > eu: 'ES',
144 > fi: 'FI',
145 > // fr: 'BE',
146 > // fr: 'CA',
147 > // fr: 'CH',
148 > fr: 'FR',
149 > he: 'IL',
150 > hr: 'HR',
151 > hu: 'HU',
152 > hy: 'AM',
153 > is: 'IS',
154 > // it: 'CH',
155 > it: 'IT',
156 > ja: 'JP',
157 > kk: 'KZ',
158 > ko: 'KR',
159 > lt: 'LT',
160 > // nl: 'BE',
161 > nl: 'NL',
162 > no: 'NO',
163 > pl: 'PL',
164 > pt: 'BR',
165 > // pt: 'PT',
166 > ro: 'RO',
167 > ru: 'RU',
168 > sk: 'SK',
169 > sl: 'SI',
170 > sr: 'YU',
171 > sv: 'SE',
172 > tr: 'TR',
173 > uk: 'UA',
174 > zh: 'CN',
175 > };
176 > if (Object.prototype.hasOwnProperty.call(languageVariants, parts[0])) {
177 > parts.push(languageVariants[parts[0]]);
178 > }
180 > // Ensure the variant is uppercase to be a valid $LANG terminalEnvironment.ts ×1
181 > parts[1] = parts[1].toUpperCase();
182 > }
183 > return parts.join('_') + '.UTF-8'; terminalEnvironment.ts ×3
184 > }
186 > export async function getCwd( terminalEnvironment.ts ×4
187 > shell: IShellLaunchConfig,
188 > userHome: string | undefined,
189 > variableResolver: VariableResolver | undefined,
190 > root: URI | undefined,
191 > customCwd: string | undefined,
192 > logService?: ILogService
193 > ): Promise<string> {
194 > if (shell.cwd) {
195 const unresolved = (typeof shell.cwd === 'object') ? shell.cwd.fsPath : shell.cwd;
196 const resolved = await _resolveCwd(unresolved, variableResolver);
197 return sanitizeCwd(resolved || unresolved);
198 }
200 > let cwd: string | undefined;
201 >
202 > if (!shell.ignoreConfigurationCwd && customCwd) {
203 > if (variableResolver) { terminalEnvironment.ts ×4
204 customCwd = await _resolveCwd(customCwd, variableResolver, logService);
205 }
206 > if (customCwd) { terminalEnvironment.ts ×4
207 > if (path.isAbsolute(customCwd)) {
208 > cwd = customCwd; terminalEnvironment.ts ×1
209 > } else if (root) { terminalEnvironment.ts ×4
210 > cwd = path.join(root.fsPath, customCwd); terminalEnvironment.ts ×1
211 > }
213 > }
215 > // If there was no custom cwd or it was relative with no workspace
216 > if (!cwd) {
217 > cwd = root ? root.fsPath : userHome || ''; terminalEnvironment.ts ×1
218 > }
220 > return sanitizeCwd(cwd);
221 > }
223 async function _resolveCwd(cwd: string, variableResolver: VariableResolver | undefined, logService?: ILogService): Promise<string | undefined> {
224 if (variableResolver) {
225 try {
226 return await variableResolver(cwd);
227 } catch (e) {
228 logService?.error('Could not resolve terminal cwd', e);
229 return undefined;
230 }
231 }
232 return cwd;
233 }
235 > export type VariableResolver = (str: string) => Promise<string>;
236 >
237 > export function createVariableResolver(lastActiveWorkspace: IWorkspaceFolder | undefined, env: IProcessEnvironment, configurationResolverService: IConfigurationResolverService | undefined): VariableResolver | undefined {
238 if (!configurationResolverService) {
239 return undefined;
240 }
241 return (str) => configurationResolverService.resolveWithEnvironment(env, lastActiveWorkspace, str);
242 }
244 > export async function createTerminalEnvironment( terminalEnvironment.ts ×7
245 > shellLaunchConfig: IShellLaunchConfig,
246 > envFromConfig: ITerminalEnvironment | undefined,
247 > variableResolver: VariableResolver | undefined,
248 > version: string | undefined,
249 > detectLocale: 'auto' | 'off' | 'on',
250 > baseEnv: IProcessEnvironment
251 > ): Promise<IProcessEnvironment> {
252 > // Create a terminal environment based on settings, launch config and permissions
253 > const env: IProcessEnvironment = {};
254 > if (shellLaunchConfig.strictEnv) {
255 // strictEnv is true, only use the requested env (ignoring null entries)
256 mergeNonNullKeys(env, shellLaunchConfig.env);
258 > // Merge process env with the env from config and from shellLaunchConfig
259 > mergeNonNullKeys(env, baseEnv);
260 >
261 > const allowedEnvFromConfig = { ...envFromConfig };
262 >
263 > // Resolve env vars from config and shell
264 > if (variableResolver) {
265 if (allowedEnvFromConfig) {
266 await resolveConfigurationVariables(variableResolver, allowedEnvFromConfig);
267 }
268 if (shellLaunchConfig.env) {
269 await resolveConfigurationVariables(variableResolver, shellLaunchConfig.env);
270 }
271 }
273 > // Workaround for https://github.com/microsoft/vscode/issues/204005
274 > // We should restore the following environment variables when a user
275 > // launches the application using the CLI so that integrated terminal
276 > // can still inherit these variables.
277 > // We are not bypassing the restrictions implied in https://github.com/electron/electron/pull/40770
278 > // since this only affects integrated terminal and not the application itself.
279 > if (isMacintosh) {
280 // Restore NODE_OPTIONS if it was set
281 if (env['VSCODE_NODE_OPTIONS']) {
282 env['NODE_OPTIONS'] = env['VSCODE_NODE_OPTIONS'];
283 delete env['VSCODE_NODE_OPTIONS'];
284 }
285
286 // Restore NODE_REPL_EXTERNAL_MODULE if it was set
287 if (env['VSCODE_NODE_REPL_EXTERNAL_MODULE']) {
288 env['NODE_REPL_EXTERNAL_MODULE'] = env['VSCODE_NODE_REPL_EXTERNAL_MODULE'];
289 delete env['VSCODE_NODE_REPL_EXTERNAL_MODULE'];
290 }
291 }
293 > // Sanitize the environment, removing any undesirable VS Code and Electron environment
294 > // variables
295 > sanitizeProcessEnvironment(env, 'VSCODE_IPC_HOOK_CLI');
296 >
297 > // Merge config (settings) and ShellLaunchConfig environments
298 > mergeEnvironments(env, allowedEnvFromConfig);
299 > mergeEnvironments(env, shellLaunchConfig.env);
300 >
301 > // Adding other env keys necessary to create the process
302 > addTerminalEnvironmentKeys(env, version, language, detectLocale);
303 > }
304 > return env;
305 > }
307 > /**
308 > * Takes a path and returns the properly escaped path to send to a given shell. On Windows, this
309 > * included trying to prepare the path for WSL if needed.
310 > *
311 > * @param originalPath The path to be escaped and formatted.
312 > * @param executable The executable off the shellLaunchConfig.
313 > * @param title The terminal's title.
314 > * @param shellType The type of shell the path is being sent to.
315 > * @param backend The backend for the terminal.
316 > * @param isWindowsFrontend Whether the frontend is Windows, this is only exposed for injection via
317 > * tests.
318 > * @returns An escaped version of the path to be executed in the terminal.
319 > */
320 > export async function preparePathForShell(resource: string | URI, executable: string | undefined, title: string, shellType: TerminalShellType | undefined, backend: Pick<ITerminalBackend, 'getWslPath'> | undefined, os: OperatingSystem | undefined, isWindowsFrontend: boolean = isWindows): Promise<string> { terminalEnvironment.ts ×6
321 > let originalPath: string;
322 > if (isString(resource)) {
323 > originalPath = resource;
324 > } else {
325 originalPath = resource.fsPath;
326 // Apply backend OS-specific formatting to the path since URI.fsPath uses the frontend's OS
327 if (isWindowsFrontend && os !== OperatingSystem.Windows) {
328 originalPath = originalPath.replace(/\\/g, '\/');
329 } else if (!isWindowsFrontend && os === OperatingSystem.Windows) {
330 originalPath = originalPath.replace(/\//g, '\\');
331 }
332 }
334 > if (!executable) {
335 return originalPath;
336 }
338 > const hasSpace = originalPath.includes(' ');
339 > const hasParens = originalPath.includes('(') || originalPath.includes(')');
340 >
341 > const pathBasename = path.basename(executable, '.exe');
342 > const isPowerShell = pathBasename === 'pwsh' ||
343 > title === 'pwsh' || terminalEnvironment.ts ×1
344 > pathBasename === 'powershell' ||
345 > title === 'powershell';
347 > if (isPowerShell && (hasSpace || originalPath.includes('\''))) {
348 > return `& '${originalPath.replace(/'/g, '\'\'')}'`; terminalEnvironment.ts ×1
349 > }
351 > if (hasParens && isPowerShell) {
352 return `& '${originalPath}'`;
353 }
355 > if (os === OperatingSystem.Windows) {
356 > // 17063 is the build number where wsl path was introduced. terminalEnvironment.ts ×2
357 > // Update Windows uriPath to be executed in WSL.
358 > if (shellType !== undefined) {
359 > if (shellType === WindowsShellType.GitBash) {
360 > return escapeNonWindowsPath(originalPath.replace(/\\/g, '/'), shellType); terminalEnvironment.ts ×1
361 > }
362 > else if (shellType === WindowsShellType.Wsl) { terminalEnvironment.ts ×1
363 > return backend?.getWslPath(originalPath, 'win-to-unix') || originalPath; terminalEnvironment.ts ×1
364 > }
365 > else if (hasSpace) { terminalEnvironment.ts ×2
366 > return `"${originalPath}"`; terminalEnvironment.ts ×1
367 > }
368 > return originalPath; terminalEnvironment.ts ×2
369 > }
370 const lowerExecutable = executable.toLowerCase();
371 > if (lowerExecutable.includes('wsl') || (lowerExecutable.includes('bash.exe') && !lowerExecutable.toLowerCase().includes('git'))) { terminalEnvironment.ts ×2
372 return backend?.getWslPath(originalPath, 'win-to-unix') || originalPath;
373 } else if (hasSpace) {
374 return `"${originalPath}"`;
375 }
376 return originalPath;
377 }
379 > return escapeNonWindowsPath(originalPath, shellType);
380 > }
382 > export function getWorkspaceForTerminal(cwd: URI | string | undefined, workspaceContextService: IWorkspaceContextService, historyService: IHistoryService): IWorkspaceFolder | undefined {
383 > const cwdUri = isString(cwd) ? URI.parse(cwd) : cwd; terminalEnvironment.ts ×2
384 > let workspaceFolder = cwdUri ? workspaceContextService.getWorkspaceFolder(cwdUri) ?? undefined : undefined;
385 > if (!workspaceFolder) {
386 > // fallback to last active workspace if cwd is not available or it is not in workspace terminalEnvironment.ts ×1
387 > // TOOD: last active workspace is known to be unreliable, we should remove this fallback eventually
388 > const activeWorkspaceRootUri = historyService.getLastActiveWorkspaceRoot();
389 > workspaceFolder = activeWorkspaceRootUri ? workspaceContextService.getWorkspaceFolder(activeWorkspaceRootUri) ?? undefined : undefined;
390 > }
391 > return workspaceFolder; terminalEnvironment.ts ×2
392 > }
394 > export async function getUriLabelForShell(uri: URI | string, backend: Pick<ITerminalBackend, 'getWslPath'>, shellType?: TerminalShellType, os?: OperatingSystem, isWindowsFrontend: boolean = isWindows): Promise<string> { terminalEnvironment.ts ×3
395 > let path = isString(uri) ? uri : uri.fsPath;
396 > if (os === OperatingSystem.Windows) {
397 > if (shellType === WindowsShellType.Wsl) { terminalEnvironment.ts ×2
398 > return backend.getWslPath(path.replaceAll('/', '\\'), 'win-to-unix'); terminalEnvironment.ts ×1
399 > } else if (shellType === WindowsShellType.GitBash) { terminalEnvironment.ts ×2
400 > // Convert \ to / and replace 'c:\' with '/c/'. terminalEnvironment.ts ×1
401 > return path.replaceAll('\\', '/').replace(/^([a-zA-Z]):\//, '/$1/');
403 > // If the frontend is not Windows but the terminal is, convert / to \. terminalEnvironment.ts ×1
404 > path = isString(uri) ? path : uriToFsPath(uri, true);
405 > return !isWindowsFrontend ? path.replaceAll('/', '\\') : path;
406 > }
408 > // If the frontend is Windows but the terminal is not, convert \ to /. terminalEnvironment.ts ×1
409 > return isWindowsFrontend ? path.replaceAll('\\', '/') : path;
410 > }
413 > /**
414 > * Gets the unified duration to wait for shell integration after the terminal launches before
415 > * declaring the terminal lacks shell integration.
416 > */
417 > export function getShellIntegrationTimeout(
418 configurationService: IConfigurationService,
419 siInjectionEnabled: boolean,
420 isRemote: boolean,
421 processReadyTimestamp?: number
422 ): number {
423 const timeoutValue = configurationService.getValue<unknown>(TerminalSettingId.ShellIntegrationTimeout);
424 let timeoutMs: number;
425 if (isNumber(timeoutValue) && timeoutValue === ShellIntegrationTimeoutOverride.DisableForTests) {
426 // Used for tests
427 timeoutMs = 0;
428 } else if (!isNumber(timeoutValue) || timeoutValue < 0) {
429 timeoutMs = siInjectionEnabled ? 5000 : (isRemote ? 3000 : 2000);
430 } else if (timeoutValue === 0) {
431 timeoutMs = 0;
432 } else {
433 timeoutMs = Math.max(timeoutValue, 500);
434 }
435
436 // Adjust timeout based on how long the process has already been running
437 if (processReadyTimestamp !== undefined) {
438 const elapsed = Date.now() - processReadyTimestamp;
439 timeoutMs = Math.max(0, timeoutMs - elapsed);
440 }
441
442 return timeoutMs;
443 }