terminalEnvironment.ts ×4

Frontier kind: Code frontier

unlabeled · c_28832b90ec32

57 tests · 4842 LOC · 22 files · introduces 0 tests · 33 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
4 ranges33 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
507 ranges4842 lines · 22 files · Browse complete extent
All tests (intent)
57 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

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 native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 33 introduced LOC across 4 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/terminal/common/terminalEnvironment.ts 33 introduced LOC · 4 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- terminalEnvironment.ts
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 > import { OperatingSystem, OS } from '../../../base/common/platform.js';
7 > import { IShellLaunchConfig, TerminalShellType, PosixShellType, WindowsShellType, GeneralShellType } from './terminal.js';
8 >
9 > /**
10 > * Aggressively escape non-windows paths to prepare for being sent to a shell. This will do some
11 > * escaping inaccurately to be careful about possible script injection via the file path. For
12 > * example, we're trying to prevent this sort of attack: `/foo/file$(echo evil)`.
13 > */
14 > export function escapeNonWindowsPath(path: string, shellType?: TerminalShellType): string {
15 let newPath = path;
16 if (newPath.includes('\\')) {
79 }
80 }
82 > /**
83 > * Collapses the user's home directory into `~` if it exists within the path, this gives a shorter
84 > * path that is more suitable within the context of a terminal.
85 > */
86 > export function collapseTildePath(path: string | undefined, userHome: string | undefined, separator: string): string {
87 if (!path) {
88 return '';
102 return `~${separator}${path.slice(userHome.length + 1)}`;
103 }
105 > /**
106 > * Sanitizes a cwd string, removing any wrapping quotes and making the Windows drive letter
107 > * uppercase.
108 > * @param cwd The directory to sanitize.
109 > */
110 > export function sanitizeCwd(cwd: string): string {
111 // Sanity check that the cwd is not wrapped in quotes (see #160109)
112 if (cwd.match(/^['"].*['"]$/)) {
119 return cwd;
120 }
122 > /**
123 > * Determines whether the given shell launch config should use the environment variable collection.
124 > * @param slc The shell launch config to check.
125 > */
126 > export function shouldUseEnvironmentVariableCollection(slc: IShellLaunchConfig): boolean {
127 return !slc.strictEnv;
128 }