-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: add timeout in searching text in files #1233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
f7b7f47
b176a12
e1d6814
a4b3dde
86bdb0e
7f0cd35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -11,6 +11,7 @@ import { URI } from '../../../util/vs/base/common/uri'; | |||||
import * as l10n from '@vscode/l10n'; | ||||||
import { ISearchService } from '../../../platform/search/common/searchService'; | ||||||
import { IWorkspaceService } from '../../../platform/workspace/common/workspaceService'; | ||||||
import { raceCancellation, raceTimeout } from '../../../util/vs/base/common/async'; | ||||||
import { CancellationToken } from '../../../util/vs/base/common/cancellation'; | ||||||
import { IInstantiationService } from '../../../util/vs/platform/instantiation/common/instantiation'; | ||||||
import { ExtendedLanguageModelToolResult, LanguageModelPromptTsxPart, MarkdownString } from '../../../vscodeTypes'; | ||||||
|
@@ -40,14 +41,34 @@ export class FindFilesTool implements ICopilotTool<IFindFilesToolParams> { | |||||
// The input _should_ be a pattern matching inside a workspace, folder, but sometimes we get absolute paths, so try to resolve them | ||||||
const pattern = inputGlobToPattern(options.input.query, this.workspaceService); | ||||||
|
||||||
const results = await this.searchService.findFiles(pattern, undefined, token); | ||||||
// try find files with a timeout of 10s | ||||||
// TODO: consider making the timeout configurable | ||||||
const timeoutInMs = 10_000; | ||||||
const results = await raceTimeout( | ||||||
raceCancellation( | ||||||
Promise.resolve(this.searchService.findFiles(pattern, undefined, token)), | ||||||
|
Promise.resolve(this.searchService.findFiles(pattern, undefined, token)), | |
this.searchService.findFiles(pattern, undefined, token), |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately the findFiles
returns a Thenable<>
which doesn't fit the required Promise<>
type, and fails compilation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would make sense for the search service to return a Promise instead (this comes from our extension API but our searchService could do the Promise.resolve
. You can do that if it makes things cleaner, you don't have to
Uh oh!
There was an error while loading. Please reload this page.