mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-07 08:26:51 +00:00
Revert to using batched file watcher to fix crash when many files would be created at once
This commit is contained in:
parent
35b9e4c85c
commit
f873a51521
1 changed files with 44 additions and 11 deletions
|
|
@ -27,25 +27,58 @@ class WorkspaceTracker {
|
|||
}
|
||||
|
||||
private registerListeners() {
|
||||
const watcher = vscode.workspace.createFileSystemWatcher("**")
|
||||
// Listen for file creation
|
||||
// .bind(this) ensures the callback refers to class instance when using this, not necessary when using arrow function
|
||||
this.disposables.push(vscode.workspace.onDidCreateFiles(this.onFilesCreated.bind(this)))
|
||||
|
||||
this.disposables.push(
|
||||
watcher.onDidCreate(async (uri) => {
|
||||
await this.addFilePath(uri.fsPath)
|
||||
this.workspaceDidUpdate()
|
||||
// Listen for file deletion
|
||||
this.disposables.push(vscode.workspace.onDidDeleteFiles(this.onFilesDeleted.bind(this)))
|
||||
|
||||
// Listen for file renaming
|
||||
this.disposables.push(vscode.workspace.onDidRenameFiles(this.onFilesRenamed.bind(this)))
|
||||
|
||||
/*
|
||||
An event that is emitted when a workspace folder is added or removed.
|
||||
**Note:** this event will not fire if the first workspace folder is added, removed or changed,
|
||||
because in that case the currently executing extensions (including the one that listens to this
|
||||
event) will be terminated and restarted so that the (deprecated) `rootPath` property is updated
|
||||
to point to the first workspace folder.
|
||||
*/
|
||||
// In other words, we don't have to worry about the root workspace folder ([0]) changing since the extension will be restarted and our cwd will be updated to reflect the new workspace folder. (We don't care about non root workspace folders, since cline will only be working within the root folder cwd)
|
||||
// this.disposables.push(vscode.workspace.onDidChangeWorkspaceFolders(this.onWorkspaceFoldersChanged.bind(this)))
|
||||
}
|
||||
|
||||
private async onFilesCreated(event: vscode.FileCreateEvent) {
|
||||
await Promise.all(
|
||||
event.files.map(async (file) => {
|
||||
await this.addFilePath(file.fsPath)
|
||||
}),
|
||||
)
|
||||
this.workspaceDidUpdate()
|
||||
}
|
||||
|
||||
// Renaming files triggers a delete and create event
|
||||
this.disposables.push(
|
||||
watcher.onDidDelete(async (uri) => {
|
||||
if (await this.removeFilePath(uri.fsPath)) {
|
||||
this.workspaceDidUpdate()
|
||||
private async onFilesDeleted(event: vscode.FileDeleteEvent) {
|
||||
let updated = false
|
||||
await Promise.all(
|
||||
event.files.map(async (file) => {
|
||||
if (await this.removeFilePath(file.fsPath)) {
|
||||
updated = true
|
||||
}
|
||||
}),
|
||||
)
|
||||
if (updated) {
|
||||
this.workspaceDidUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
this.disposables.push(watcher)
|
||||
private async onFilesRenamed(event: vscode.FileRenameEvent) {
|
||||
await Promise.all(
|
||||
event.files.map(async (file) => {
|
||||
await this.removeFilePath(file.oldUri.fsPath)
|
||||
await this.addFilePath(file.newUri.fsPath)
|
||||
}),
|
||||
)
|
||||
this.workspaceDidUpdate()
|
||||
}
|
||||
|
||||
private workspaceDidUpdate() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue