117
118
private async _enumerate(workingDirectory: URI): Promise<readonly URI[]> {
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
}
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
}
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;