fix(opencode): add AbortSignal support to Ripgrep.files() and GlobTool (#10833)

This commit is contained in:
Goni Zahavy 2026-01-29 02:47:09 +02:00 • committed by GitHub
commit e5b33f8a5e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 3 deletions

View file

@ -38,6 +38,7 @@ export const GlobTool = Tool.define("glob", {
for await (const file of Ripgrep.files({
cwd: search,
glob: [params.pattern],
signal: ctx.abort,
})) {
if (files.length >= limit) {
truncated = true

View file

@ -56,7 +56,7 @@ export const ListTool = Tool.define("list", {
const ignoreGlobs = IGNORE_PATTERNS.map((p) => `!${p}*`).concat(params.ignore?.map((p) => `!${p}`) || [])
const files = []
for await (const file of Ripgrep.files({ cwd: searchPath, glob: ignoreGlobs })) {
for await (const file of Ripgrep.files({ cwd: searchPath, glob: ignoreGlobs, signal: ctx.abort })) {
files.push(file)
if (files.length >= LIMIT) break
}