From 912850c31c50a0bce2da367d54bf8763c3a0ad3a Mon Sep 17 00:00:00 2001 From: Matt Rubens Date: Thu, 26 Dec 2024 08:05:07 -0800 Subject: [PATCH 1/2] Updated workspace tracker from Cline --- src/integrations/workspace/WorkspaceTracker.ts | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/integrations/workspace/WorkspaceTracker.ts b/src/integrations/workspace/WorkspaceTracker.ts index 69fc860..29a4c37 100644 --- a/src/integrations/workspace/WorkspaceTracker.ts +++ b/src/integrations/workspace/WorkspaceTracker.ts @@ -27,10 +27,8 @@ class WorkspaceTracker { } private registerListeners() { - // Create a file system watcher for all files - const watcher = vscode.workspace.createFileSystemWatcher('**') + const watcher = vscode.workspace.createFileSystemWatcher("**") - // Listen for file creation this.disposables.push( watcher.onDidCreate(async (uri) => { await this.addFilePath(uri.fsPath) @@ -38,7 +36,7 @@ class WorkspaceTracker { }) ) - // Listen for file deletion + // Renaming files triggers a delete and create event this.disposables.push( watcher.onDidDelete(async (uri) => { if (await this.removeFilePath(uri.fsPath)) { @@ -47,15 +45,6 @@ class WorkspaceTracker { }) ) - // Listen for file changes (which could include renames) - this.disposables.push( - watcher.onDidChange(async (uri) => { - await this.addFilePath(uri.fsPath) - this.workspaceDidUpdate() - }) - ) - - // Add the watcher itself to disposables this.disposables.push(watcher) } @@ -68,7 +57,7 @@ class WorkspaceTracker { filePaths: Array.from(this.filePaths).map((file) => { const relativePath = path.relative(cwd, file).toPosix() return file.endsWith("/") ? relativePath + "/" : relativePath - }), + }) }) } From 2b46a307b582bf21803cab219d157030c6592295 Mon Sep 17 00:00:00 2001 From: Matt Rubens Date: Thu, 26 Dec 2024 08:24:02 -0800 Subject: [PATCH 2/2] Update tests --- .../workspace/__tests__/WorkspaceTracker.test.ts | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/integrations/workspace/__tests__/WorkspaceTracker.test.ts b/src/integrations/workspace/__tests__/WorkspaceTracker.test.ts index 1398851..c6bd62a 100644 --- a/src/integrations/workspace/__tests__/WorkspaceTracker.test.ts +++ b/src/integrations/workspace/__tests__/WorkspaceTracker.test.ts @@ -12,7 +12,6 @@ const mockDispose = jest.fn() const mockWatcher = { onDidCreate: mockOnDidCreate.mockReturnValue({ dispose: mockDispose }), onDidDelete: mockOnDidDelete.mockReturnValue({ dispose: mockDispose }), - onDidChange: mockOnDidChange.mockReturnValue({ dispose: mockDispose }), dispose: mockDispose } @@ -86,16 +85,6 @@ describe("WorkspaceTracker", () => { }) }) - it("should handle file change events", async () => { - const [[callback]] = mockOnDidChange.mock.calls - await callback({ fsPath: "/test/workspace/changed.ts" }) - - expect(mockProvider.postMessageToWebview).toHaveBeenCalledWith({ - type: "workspaceUpdated", - filePaths: ["changed.ts"] - }) - }) - it("should handle directory paths correctly", async () => { // Mock stat to return directory type ;(vscode.workspace.fs.stat as jest.Mock).mockResolvedValueOnce({ type: 2 }) // FileType.Directory = 2