agentHostWorkspaceFiles.ts ×12

Frontier kind: Code frontier

unlabeled · c_ce16466b32da

6 tests · 8305 LOC · 39 files · introduces 0 tests · 66 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
12 ranges66 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1384 ranges8305 lines · 39 files · Browse complete extent
All tests (intent)
6 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: 66 introduced LOC across 12 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/agentHostWorkspaceFiles.ts 66 introduced LOC · 12 ranges

Open complete file

72 return [];
73 }
75 > const key = workingDirectory.toString();
76 > const now = Date.now();
77 > const existing = this._cache.get(key);
78 > let shared: Promise<readonly URI[]>;
79 if (existing && existing.expiresAt > now) {
80 shared = existing.promise;
82 > shared = this._enumerate(workingDirectory);
83 > const entry: ICacheEntry = { promise: shared, expiresAt: now + CACHE_TTL_MS };
84 > this._cache.set(key, entry);
85 > // If enumeration fails, drop the cache entry so the next caller retries.
86 > shared.catch(() => {
87 if (this._cache.get(key) === entry) {
88 this._cache.delete(key);
89 }
91 > }
92 >
93 > // Race the shared enumeration against the caller's cancellation
94 > // token. Only the caller's promise rejects on cancellation; the
95 > // shared enumeration runs to completion so concurrent callers (and
96 > // future cache hits within the TTL) still see the result.
97 > if (token.isCancellationRequested) {
98 throw new CancellationError();
99 }
100 > if (token === CancellationToken.None) { agentHostWorkspaceFiles.ts
101 return shared;
102 }
117
118 private async _enumerate(workingDirectory: URI): Promise<readonly URI[]> {
119 > const resolvedRgDiskPath = await rgDiskPath(); agentHostWorkspaceFiles.ts
120 > return new Promise<readonly URI[]>(resolve => {
121 > const cwd = workingDirectory.fsPath;
122 > // Mirror the workbench's `ripgrepFileSearch.ts` invocation: pass
123 > // `--no-config` so a user's global `~/.ripgreprc` cannot change
124 > // enumeration results (or enable preprocessors etc.).
125 > const args = ['--files', '--hidden', '--no-require-git', '--follow', '--no-config', '--glob', '!.git'];
126 >
127 > let child: cp.ChildProcessWithoutNullStreams;
128 > try {
129 > child = cp.spawn(resolvedRgDiskPath, args, { cwd });
130 > } catch (err) {
131 this._logService.warn(`[AgentHostWorkspaceFiles] Failed to spawn ripgrep: ${err}`);
132 resolve([]);
133 return;
134 }
135 > this._activeChildren.add(child); agentHostWorkspaceFiles.ts
136 >
137 > const results: URI[] = [];
138 > let buffer = '';
139 > let limitHit = false;
140 > let settled = false;
141 >
142 > const finish = (value: readonly URI[]) => {
143 > if (settled) {
144 return;
145 }
146 > settled = true; agentHostWorkspaceFiles.ts
147 > this._activeChildren.delete(child);
148 > resolve(value);
149 > };
150 >
151 > child.stdout.setEncoding('utf8');
152 > child.stdout.on('data', (chunk: string) => {
153 if (limitHit) {
154 return;
173 }
174 }
176 >
177 > child.stderr.setEncoding('utf8');
178 > let stderr = '';
179 > child.stderr.on('data', (chunk: string) => {
180 stderr += chunk;
182 >
183 > child.on('error', err => {
184 this._logService.warn(`[AgentHostWorkspaceFiles] ripgrep error: ${err}`);
185 finish([]);
187 >
188 > child.on('close', () => {
189 > // Flush any trailing line still in the buffer.
190 > if (!limitHit && buffer.length > 0) {
191 const line = buffer.replace(/\r$/, '');
192 if (line) {