history.ts ×6

Frontier kind: Code frontier

unlabeled · c_b4088e3426c7

4 tests · 25374 LOC · 131 files · introduces 0 tests · 58 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
6 ranges58 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2846 ranges25374 lines · 131 files · Browse complete extent
All tests (intent)
4 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: 58 introduced LOC across 6 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/terminalContrib/history/common/history.ts 58 introduced LOC · 6 ranges

Open complete file

350 }
351
352 > export async function fetchPwshHistory(accessor: ServicesAccessor): Promise<IShellFileHistoryEntry | undefined> { history.ts
353 > const fileService: Pick<IFileService, 'readFile'> = accessor.get(IFileService);
354 > const remoteAgentService: Pick<IRemoteAgentService, 'getConnection' | 'getEnvironment'> = accessor.get(IRemoteAgentService);
355 > let folderPrefix: string | undefined;
356 > let filePath: string;
357 > const remoteEnvironment = await remoteAgentService.getEnvironment();
358 > const isFileWindows = remoteEnvironment?.os === OperatingSystem.Windows || !remoteEnvironment && isWindows;
359 > let sourceLabel: string;
360 > if (isFileWindows) {
361 folderPrefix = env['APPDATA'];
362 filePath = 'Microsoft\\Windows\\PowerShell\\PSReadLine\\ConsoleHost_history.txt';
363 sourceLabel = `$APPDATA\\Microsoft\\Windows\\PowerShell\\PSReadLine\\ConsoleHost_history.txt`;
364 > } else { history.ts
365 folderPrefix = remoteEnvironment?.userHome?.fsPath ?? env['HOME'];
366 filePath = '.local/share/powershell/PSReadline/ConsoleHost_history.txt';
367 sourceLabel = `~/${filePath}`;
368 }
369 > const resolvedFile = await fetchFileContents(folderPrefix, filePath, isFileWindows, fileService, remoteAgentService); history.ts
370 > if (resolvedFile === undefined) {
371 return undefined;
372 }
373 > const fileLines = resolvedFile.content.split('\n'); history.ts
374 > const result: Set<string> = new Set();
375 > let currentLine: string;
376 > let currentCommand: string | undefined = undefined;
377 > let wrapChar: string | undefined = undefined;
378 > for (let i = 0; i < fileLines.length; i++) {
379 > currentLine = fileLines[i];
380 > if (currentCommand === undefined) {
381 > currentCommand = currentLine;
382 > } else {
383 > currentCommand += `\n${currentLine}`;
384 > }
385 > if (!currentLine.endsWith('`')) {
386 > const sanitized = currentCommand.trim();
387 > if (sanitized.length > 0) {
388 > result.add(sanitized);
389 > }
390 > currentCommand = undefined;
391 > continue;
392 > }
393 > // If the line ends with `, the line may be wrapped. Need to also test the case where ` is
394 > // the last character in the line
395 > for (let c = 0; c < currentLine.length; c++) {
396 > if (wrapChar) {
397 if (currentLine[c] === wrapChar) {
398 wrapChar = undefined;
399 }
400 > } else { history.ts
401 > if (currentLine[c].match(/`/)) {
402 > wrapChar = currentLine[c];
403 > }
404 > }
405 > }
406 > // Having an even number of backticks means the line is terminated
407 > // TODO: This doesn't cover more complicated cases where ` is within quotes
408 > if (!wrapChar) {
409 const sanitized = currentCommand.trim();
410 if (sanitized.length > 0) {
412 }
413 currentCommand = undefined;
414 > } else { history.ts
415 > // Remove trailing backtick
416 > currentCommand = currentCommand.replace(/`$/, '');
417 > wrapChar = undefined;
418 > }
419 > }
420 >
421 > return {
422 > sourceLabel,
423 > sourceResource: resolvedFile.resource,
424 > commands: Array.from(result.values())
425 > };
426 > }
427
428 export async function fetchFishHistory(accessor: ServicesAccessor): Promise<IShellFileHistoryEntry | undefined> {