From d86d894b5f050f8717d8f2026baf3fff7bcd87d9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Jun 2025 16:35:53 +0000 Subject: [PATCH 1/7] Initial plan From 2960abf42b57c83f602307b590fc5731b028ffbc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Jun 2025 16:46:37 +0000 Subject: [PATCH 2/7] Implement file system watchers for project moves and deletions Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com> --- src/common/workspace.apis.ts | 9 ++ src/features/projectManager.ts | 29 ++++++ src/features/views/projectView.ts | 62 ++++++++++++- src/internal.api.ts | 1 + .../projectManager.updateUri.unit.test.ts | 88 +++++++++++++++++++ 5 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 src/test/features/projectManager.updateUri.unit.test.ts diff --git a/src/common/workspace.apis.ts b/src/common/workspace.apis.ts index 213c0b8a..c009cd6d 100644 --- a/src/common/workspace.apis.ts +++ b/src/common/workspace.apis.ts @@ -5,6 +5,7 @@ import { ConfigurationScope, Disposable, FileDeleteEvent, + FileRenameEvent, FileSystemWatcher, GlobPattern, Uri, @@ -63,3 +64,11 @@ export function onDidDeleteFiles( ): Disposable { return workspace.onDidDeleteFiles(listener, thisArgs, disposables); } + +export function onDidRenameFiles( + listener: (e: FileRenameEvent) => any, + thisArgs?: any, + disposables?: Disposable[], +): Disposable { + return workspace.onDidRenameFiles(listener, thisArgs, disposables); +} diff --git a/src/features/projectManager.ts b/src/features/projectManager.ts index 733278a9..e7a74cef 100644 --- a/src/features/projectManager.ts +++ b/src/features/projectManager.ts @@ -170,6 +170,35 @@ export class PythonProjectManagerImpl implements PythonProjectManager { this._onDidChangeProjects.fire(Array.from(this._projects.values())); } + updateProjectUri(oldUri: Uri, newUri: Uri): void { + const oldKey = oldUri.toString(); + const project = this._projects.get(oldKey); + + if (!project) { + return; + } + + // Remove the project with the old URI + this._projects.delete(oldKey); + + // Create a new project instance with the updated URI + const updatedProject = this.create( + path.basename(newUri.fsPath), + newUri, + { + description: project.description, + tooltip: project.tooltip, + iconPath: (project as PythonProjectsImpl).iconPath, // Cast to implementation to access iconPath + } + ); + + // Add the updated project + this._projects.set(newUri.toString(), updatedProject); + + // Fire the change event to update the view + this._onDidChangeProjects.fire(Array.from(this._projects.values())); + } + getProjects(uris?: Uri[]): ReadonlyArray { if (uris === undefined) { return Array.from(this._projects.values()); diff --git a/src/features/views/projectView.ts b/src/features/views/projectView.ts index 2c405a07..0c3c7777 100644 --- a/src/features/views/projectView.ts +++ b/src/features/views/projectView.ts @@ -12,7 +12,7 @@ import { import { PythonEnvironment } from '../../api'; import { ProjectViews } from '../../common/localize'; import { createSimpleDebounce } from '../../common/utils/debounce'; -import { onDidChangeConfiguration } from '../../common/workspace.apis'; +import { onDidChangeConfiguration, onDidDeleteFiles, onDidRenameFiles } from '../../common/workspace.apis'; import { EnvironmentManagers, PythonProjectManager } from '../../internal.api'; import { GlobalProjectItem, @@ -68,6 +68,12 @@ export class ProjectView implements TreeDataProvider { this.debouncedUpdateProject.trigger(); } }), + onDidRenameFiles((e) => { + this.handleFileRenames(e); + }), + onDidDeleteFiles((e) => { + this.handleFileDeletions(e); + }), ); } @@ -224,6 +230,60 @@ export class ProjectView implements TreeDataProvider { return element.parent; } + private handleFileRenames(e: { readonly files: ReadonlyArray<{ readonly oldUri: Uri; readonly newUri: Uri }> }): void { + const projects = this.projectManager.getProjects(); + + for (const { oldUri, newUri } of e.files) { + // Check if any project matches the old URI exactly or is contained within it + const affectedProjects = projects.filter(project => { + const projectPath = project.uri.fsPath; + const oldPath = oldUri.fsPath; + + // Check if the project path is the same as or is a child of the renamed path + return projectPath === oldPath || projectPath.startsWith(oldPath + '/') || projectPath.startsWith(oldPath + '\\'); + }); + + for (const project of affectedProjects) { + const projectPath = project.uri.fsPath; + const oldPath = oldUri.fsPath; + const newPath = newUri.fsPath; + + // Calculate the new project path + let newProjectPath: string; + if (projectPath === oldPath) { + // Project path is exactly the renamed path + newProjectPath = newPath; + } else { + // Project path is a child of the renamed path + const relativePath = projectPath.substring(oldPath.length); + newProjectPath = newPath + relativePath; + } + + const newProjectUri = Uri.file(newProjectPath); + this.projectManager.updateProjectUri(project.uri, newProjectUri); + } + } + } + + private handleFileDeletions(e: { readonly files: ReadonlyArray }): void { + const projects = this.projectManager.getProjects(); + + for (const deletedUri of e.files) { + // Check if any project matches the deleted URI exactly or is contained within it + const affectedProjects = projects.filter(project => { + const projectPath = project.uri.fsPath; + const deletedPath = deletedUri.fsPath; + + // Check if the project path is the same as or is a child of the deleted path + return projectPath === deletedPath || projectPath.startsWith(deletedPath + '/') || projectPath.startsWith(deletedPath + '\\'); + }); + + if (affectedProjects.length > 0) { + this.projectManager.remove(affectedProjects); + } + } + } + dispose() { this.disposables.forEach((d) => d.dispose()); } diff --git a/src/internal.api.ts b/src/internal.api.ts index ce258e31..68ee0a40 100644 --- a/src/internal.api.ts +++ b/src/internal.api.ts @@ -287,6 +287,7 @@ export interface PythonProjectManager extends Disposable { ): PythonProject; add(pyWorkspace: PythonProject | PythonProject[]): Promise; remove(pyWorkspace: PythonProject | PythonProject[]): void; + updateProjectUri(oldUri: Uri, newUri: Uri): void; getProjects(uris?: Uri[]): ReadonlyArray; get(uri: Uri): PythonProject | undefined; onDidChangeProjects: Event; diff --git a/src/test/features/projectManager.updateUri.unit.test.ts b/src/test/features/projectManager.updateUri.unit.test.ts new file mode 100644 index 00000000..83b8f665 --- /dev/null +++ b/src/test/features/projectManager.updateUri.unit.test.ts @@ -0,0 +1,88 @@ +import assert from 'assert'; +import { Uri } from 'vscode'; +import { PythonProjectManagerImpl } from '../../features/projectManager'; + +suite('Project Manager Update URI tests', () => { + let projectManager: PythonProjectManagerImpl; + + setup(() => { + projectManager = new PythonProjectManagerImpl(); + }); + + teardown(() => { + projectManager.dispose(); + }); + + test('updateProjectUri should update existing project URI', () => { + const oldUri = Uri.file('/path/to/old/project'); + const newUri = Uri.file('/path/to/new/project'); + + // Create a project and manually add it to the internal map to bypass the complex add method + const project = projectManager.create('TestProject', oldUri, { + description: 'Test project', + tooltip: 'Test tooltip' + }); + + // Access private _projects map to manually add the project for testing + (projectManager as any)._projects.set(oldUri.toString(), project); + + // Verify project exists with old URI + const oldProject = projectManager.get(oldUri); + assert.ok(oldProject, 'Project should exist with old URI'); + assert.equal(oldProject.uri.fsPath, oldUri.fsPath, 'Old URI should match'); + + // Update the project URI + projectManager.updateProjectUri(oldUri, newUri); + + // Verify project no longer exists with old URI + const oldProjectAfterUpdate = projectManager.get(oldUri); + assert.equal(oldProjectAfterUpdate, undefined, 'Project should not exist with old URI after update'); + + // Verify project exists with new URI + const newProject = projectManager.get(newUri); + assert.ok(newProject, 'Project should exist with new URI'); + assert.equal(newProject.uri.fsPath, newUri.fsPath, 'New URI should match'); + assert.equal(newProject.name, 'project', 'Project name should be based on new path'); + assert.equal(newProject.description, 'Test project', 'Description should be preserved'); + assert.equal(newProject.tooltip, 'Test tooltip', 'Tooltip should be preserved'); + }); + + test('updateProjectUri should handle non-existent project gracefully', () => { + const oldUri = Uri.file('/path/to/nonexistent/project'); + const newUri = Uri.file('/path/to/new/project'); + + // Try to update a project that doesn't exist + // This should not throw an error + assert.doesNotThrow(() => { + projectManager.updateProjectUri(oldUri, newUri); + }, 'Should handle non-existent project gracefully'); + + // Verify no project was created + const newProject = projectManager.get(newUri); + assert.equal(newProject, undefined, 'No project should be created for non-existent old project'); + }); + + test('remove should remove multiple projects', () => { + const project1Uri = Uri.file('/path/to/project1'); + const project2Uri = Uri.file('/path/to/project2'); + + // Create projects and manually add them to the internal map + const project1 = projectManager.create('Project1', project1Uri); + const project2 = projectManager.create('Project2', project2Uri); + + // Access private _projects map to manually add projects for testing + (projectManager as any)._projects.set(project1Uri.toString(), project1); + (projectManager as any)._projects.set(project2Uri.toString(), project2); + + // Verify both projects exist + assert.ok(projectManager.get(project1Uri), 'Project1 should exist'); + assert.ok(projectManager.get(project2Uri), 'Project2 should exist'); + + // Remove both projects + projectManager.remove([project1, project2]); + + // Verify both projects are removed + assert.equal(projectManager.get(project1Uri), undefined, 'Project1 should be removed'); + assert.equal(projectManager.get(project2Uri), undefined, 'Project2 should be removed'); + }); +}); \ No newline at end of file From ba89af256e6e288b9fc09f22e6f8b96f72c89fa3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Jun 2025 16:48:55 +0000 Subject: [PATCH 3/7] Fix test TypeScript casting warnings Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com> --- src/test/features/projectManager.updateUri.unit.test.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/test/features/projectManager.updateUri.unit.test.ts b/src/test/features/projectManager.updateUri.unit.test.ts index 83b8f665..0ae1d52e 100644 --- a/src/test/features/projectManager.updateUri.unit.test.ts +++ b/src/test/features/projectManager.updateUri.unit.test.ts @@ -1,5 +1,6 @@ import assert from 'assert'; import { Uri } from 'vscode'; +import { PythonProject } from '../../api'; import { PythonProjectManagerImpl } from '../../features/projectManager'; suite('Project Manager Update URI tests', () => { @@ -24,7 +25,7 @@ suite('Project Manager Update URI tests', () => { }); // Access private _projects map to manually add the project for testing - (projectManager as any)._projects.set(oldUri.toString(), project); + (projectManager as unknown as { _projects: Map })._projects.set(oldUri.toString(), project); // Verify project exists with old URI const oldProject = projectManager.get(oldUri); @@ -71,8 +72,9 @@ suite('Project Manager Update URI tests', () => { const project2 = projectManager.create('Project2', project2Uri); // Access private _projects map to manually add projects for testing - (projectManager as any)._projects.set(project1Uri.toString(), project1); - (projectManager as any)._projects.set(project2Uri.toString(), project2); + const pmWithPrivateAccess = projectManager as unknown as { _projects: Map }; + pmWithPrivateAccess._projects.set(project1Uri.toString(), project1); + pmWithPrivateAccess._projects.set(project2Uri.toString(), project2); // Verify both projects exist assert.ok(projectManager.get(project1Uri), 'Project1 should exist'); From 918ba668f16af66da53b85238c691eef248fad4f Mon Sep 17 00:00:00 2001 From: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com> Date: Wed, 25 Jun 2025 11:52:46 -0700 Subject: [PATCH 4/7] updateprojecturi to updateproject and include debounce updates --- src/features/projectManager.ts | 54 ++++++++++--------- src/features/views/projectView.ts | 45 +++++++++++----- src/internal.api.ts | 7 ++- .../projectManager.updateUri.unit.test.ts | 17 +++--- 4 files changed, 77 insertions(+), 46 deletions(-) diff --git a/src/features/projectManager.ts b/src/features/projectManager.ts index e7a74cef..5d84b3a1 100644 --- a/src/features/projectManager.ts +++ b/src/features/projectManager.ts @@ -170,33 +170,39 @@ export class PythonProjectManagerImpl implements PythonProjectManager { this._onDidChangeProjects.fire(Array.from(this._projects.values())); } - updateProjectUri(oldUri: Uri, newUri: Uri): void { - const oldKey = oldUri.toString(); - const project = this._projects.get(oldKey); - + /** + * Update a project by removing the old one and adding a new one with updated properties. + * @param existingUri The URI of the project to update. + * @param newName The new name for the project (optional, defaults to old name). + * @param newUri The new URI for the project (optional, defaults to old URI). + * @param newOptions New options for the project (optional, merged with old options). + */ + async updateProject( + existingUri: Uri, + newName?: string, + newUri?: Uri, + newOptions?: { description?: string; tooltip?: string | MarkdownString; iconPath?: IconPath }, + ): Promise { + const project = this.get(existingUri); if (!project) { return; } - // Remove the project with the old URI - this._projects.delete(oldKey); - - // Create a new project instance with the updated URI - const updatedProject = this.create( - path.basename(newUri.fsPath), - newUri, - { - description: project.description, - tooltip: project.tooltip, - iconPath: (project as PythonProjectsImpl).iconPath, // Cast to implementation to access iconPath - } - ); - - // Add the updated project - this._projects.set(newUri.toString(), updatedProject); - - // Fire the change event to update the view - this._onDidChangeProjects.fire(Array.from(this._projects.values())); + // Remove the old project + this.remove(project); + + // Prepare new values + const name = newName ?? project.name; + const uri = newUri ?? project.uri; + const options = { + description: newOptions?.description ?? project.description, + tooltip: newOptions?.tooltip ?? project.tooltip, + iconPath: newOptions?.iconPath ?? (project as PythonProjectsImpl).iconPath, + }; + + // Create and add the new project + const updatedProject = this.create(name, uri, options); + await this.add(updatedProject); } getProjects(uris?: Uri[]): ReadonlyArray { @@ -212,7 +218,7 @@ export class PythonProjectManagerImpl implements PythonProjectManager { } return projects; } - } + }0 get(uri: Uri): PythonProject | undefined { let pythonProject = this._projects.get(uri.toString()); diff --git a/src/features/views/projectView.ts b/src/features/views/projectView.ts index 0c3c7777..0f76f25d 100644 --- a/src/features/views/projectView.ts +++ b/src/features/views/projectView.ts @@ -230,24 +230,30 @@ export class ProjectView implements TreeDataProvider { return element.parent; } - private handleFileRenames(e: { readonly files: ReadonlyArray<{ readonly oldUri: Uri; readonly newUri: Uri }> }): void { + private async handleFileRenames(e: { + readonly files: ReadonlyArray<{ readonly oldUri: Uri; readonly newUri: Uri }>; + }): Promise { const projects = this.projectManager.getProjects(); - + for (const { oldUri, newUri } of e.files) { // Check if any project matches the old URI exactly or is contained within it - const affectedProjects = projects.filter(project => { + const affectedProjects = projects.filter((project) => { const projectPath = project.uri.fsPath; const oldPath = oldUri.fsPath; - + // Check if the project path is the same as or is a child of the renamed path - return projectPath === oldPath || projectPath.startsWith(oldPath + '/') || projectPath.startsWith(oldPath + '\\'); + return ( + projectPath === oldPath || + projectPath.startsWith(oldPath + '/') || + projectPath.startsWith(oldPath + '\\') + ); }); - + for (const project of affectedProjects) { const projectPath = project.uri.fsPath; const oldPath = oldUri.fsPath; const newPath = newUri.fsPath; - + // Calculate the new project path let newProjectPath: string; if (projectPath === oldPath) { @@ -258,28 +264,39 @@ export class ProjectView implements TreeDataProvider { const relativePath = projectPath.substring(oldPath.length); newProjectPath = newPath + relativePath; } - + const newProjectUri = Uri.file(newProjectPath); - this.projectManager.updateProjectUri(project.uri, newProjectUri); + await this.projectManager.updateProject(project.uri, undefined, newProjectUri); + } + + if (affectedProjects.length > 0) { + // only trigger update if there are affected projects + this.debouncedUpdateProject.trigger(); } } } private handleFileDeletions(e: { readonly files: ReadonlyArray }): void { const projects = this.projectManager.getProjects(); - + for (const deletedUri of e.files) { // Check if any project matches the deleted URI exactly or is contained within it - const affectedProjects = projects.filter(project => { + const affectedProjects = projects.filter((project) => { const projectPath = project.uri.fsPath; const deletedPath = deletedUri.fsPath; - + // Check if the project path is the same as or is a child of the deleted path - return projectPath === deletedPath || projectPath.startsWith(deletedPath + '/') || projectPath.startsWith(deletedPath + '\\'); + return ( + projectPath === deletedPath || + projectPath.startsWith(deletedPath + '/') || + projectPath.startsWith(deletedPath + '\\') + ); }); - + if (affectedProjects.length > 0) { this.projectManager.remove(affectedProjects); + // If there are affected projects, trigger an update + this.debouncedUpdateProject.trigger(); } } } diff --git a/src/internal.api.ts b/src/internal.api.ts index 68ee0a40..b3f27280 100644 --- a/src/internal.api.ts +++ b/src/internal.api.ts @@ -287,7 +287,12 @@ export interface PythonProjectManager extends Disposable { ): PythonProject; add(pyWorkspace: PythonProject | PythonProject[]): Promise; remove(pyWorkspace: PythonProject | PythonProject[]): void; - updateProjectUri(oldUri: Uri, newUri: Uri): void; + updateProject( + existingUri: Uri, + newName?: string, + newUri?: Uri, + newOptions?: { description?: string; tooltip?: string | MarkdownString; iconPath?: IconPath }, + ): Promise; getProjects(uris?: Uri[]): ReadonlyArray; get(uri: Uri): PythonProject | undefined; onDidChangeProjects: Event; diff --git a/src/test/features/projectManager.updateUri.unit.test.ts b/src/test/features/projectManager.updateUri.unit.test.ts index 0ae1d52e..98f0d059 100644 --- a/src/test/features/projectManager.updateUri.unit.test.ts +++ b/src/test/features/projectManager.updateUri.unit.test.ts @@ -21,11 +21,14 @@ suite('Project Manager Update URI tests', () => { // Create a project and manually add it to the internal map to bypass the complex add method const project = projectManager.create('TestProject', oldUri, { description: 'Test project', - tooltip: 'Test tooltip' + tooltip: 'Test tooltip', }); - + // Access private _projects map to manually add the project for testing - (projectManager as unknown as { _projects: Map })._projects.set(oldUri.toString(), project); + (projectManager as unknown as { _projects: Map })._projects.set( + oldUri.toString(), + project, + ); // Verify project exists with old URI const oldProject = projectManager.get(oldUri); @@ -33,7 +36,7 @@ suite('Project Manager Update URI tests', () => { assert.equal(oldProject.uri.fsPath, oldUri.fsPath, 'Old URI should match'); // Update the project URI - projectManager.updateProjectUri(oldUri, newUri); + projectManager.updateProject(oldUri, 'project', newUri); // Verify project no longer exists with old URI const oldProjectAfterUpdate = projectManager.get(oldUri); @@ -55,7 +58,7 @@ suite('Project Manager Update URI tests', () => { // Try to update a project that doesn't exist // This should not throw an error assert.doesNotThrow(() => { - projectManager.updateProjectUri(oldUri, newUri); + projectManager.updateProject(oldUri, 'project', newUri); }, 'Should handle non-existent project gracefully'); // Verify no project was created @@ -70,7 +73,7 @@ suite('Project Manager Update URI tests', () => { // Create projects and manually add them to the internal map const project1 = projectManager.create('Project1', project1Uri); const project2 = projectManager.create('Project2', project2Uri); - + // Access private _projects map to manually add projects for testing const pmWithPrivateAccess = projectManager as unknown as { _projects: Map }; pmWithPrivateAccess._projects.set(project1Uri.toString(), project1); @@ -87,4 +90,4 @@ suite('Project Manager Update URI tests', () => { assert.equal(projectManager.get(project1Uri), undefined, 'Project1 should be removed'); assert.equal(projectManager.get(project2Uri), undefined, 'Project2 should be removed'); }); -}); \ No newline at end of file +}); From 3524018aa007c2e03cff7b89599a53bcf5b56af4 Mon Sep 17 00:00:00 2001 From: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com> Date: Wed, 25 Jun 2025 11:53:03 -0700 Subject: [PATCH 5/7] error --- src/features/projectManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/projectManager.ts b/src/features/projectManager.ts index 5d84b3a1..d440c275 100644 --- a/src/features/projectManager.ts +++ b/src/features/projectManager.ts @@ -218,7 +218,7 @@ export class PythonProjectManagerImpl implements PythonProjectManager { } return projects; } - }0 + } get(uri: Uri): PythonProject | undefined { let pythonProject = this._projects.get(uri.toString()); From c9d5b864771cd4ee23e07a648163a286e0520c59 Mon Sep 17 00:00:00 2001 From: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com> Date: Wed, 25 Jun 2025 11:55:04 -0700 Subject: [PATCH 6/7] rename --- src/features/projectManager.ts | 2 +- src/features/views/projectView.ts | 2 +- src/internal.api.ts | 2 +- src/test/features/projectManager.updateUri.unit.test.ts | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/features/projectManager.ts b/src/features/projectManager.ts index d440c275..41b9b84c 100644 --- a/src/features/projectManager.ts +++ b/src/features/projectManager.ts @@ -177,7 +177,7 @@ export class PythonProjectManagerImpl implements PythonProjectManager { * @param newUri The new URI for the project (optional, defaults to old URI). * @param newOptions New options for the project (optional, merged with old options). */ - async updateProject( + async modifyProject( existingUri: Uri, newName?: string, newUri?: Uri, diff --git a/src/features/views/projectView.ts b/src/features/views/projectView.ts index 0f76f25d..70031638 100644 --- a/src/features/views/projectView.ts +++ b/src/features/views/projectView.ts @@ -266,7 +266,7 @@ export class ProjectView implements TreeDataProvider { } const newProjectUri = Uri.file(newProjectPath); - await this.projectManager.updateProject(project.uri, undefined, newProjectUri); + await this.projectManager.modifyProject(project.uri, undefined, newProjectUri); } if (affectedProjects.length > 0) { diff --git a/src/internal.api.ts b/src/internal.api.ts index b3f27280..3f2676c6 100644 --- a/src/internal.api.ts +++ b/src/internal.api.ts @@ -287,7 +287,7 @@ export interface PythonProjectManager extends Disposable { ): PythonProject; add(pyWorkspace: PythonProject | PythonProject[]): Promise; remove(pyWorkspace: PythonProject | PythonProject[]): void; - updateProject( + modifyProject( existingUri: Uri, newName?: string, newUri?: Uri, diff --git a/src/test/features/projectManager.updateUri.unit.test.ts b/src/test/features/projectManager.updateUri.unit.test.ts index 98f0d059..e1c718cf 100644 --- a/src/test/features/projectManager.updateUri.unit.test.ts +++ b/src/test/features/projectManager.updateUri.unit.test.ts @@ -36,7 +36,7 @@ suite('Project Manager Update URI tests', () => { assert.equal(oldProject.uri.fsPath, oldUri.fsPath, 'Old URI should match'); // Update the project URI - projectManager.updateProject(oldUri, 'project', newUri); + projectManager.modifyProject(oldUri, 'project', newUri); // Verify project no longer exists with old URI const oldProjectAfterUpdate = projectManager.get(oldUri); @@ -58,7 +58,7 @@ suite('Project Manager Update URI tests', () => { // Try to update a project that doesn't exist // This should not throw an error assert.doesNotThrow(() => { - projectManager.updateProject(oldUri, 'project', newUri); + projectManager.modifyProject(oldUri, 'project', newUri); }, 'Should handle non-existent project gracefully'); // Verify no project was created From b712b7cfedd31f741360e0434b8a0167319a47da Mon Sep 17 00:00:00 2001 From: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com> Date: Wed, 25 Jun 2025 13:08:10 -0700 Subject: [PATCH 7/7] fix tests --- src/test/features/projectManager.updateUri.unit.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/features/projectManager.updateUri.unit.test.ts b/src/test/features/projectManager.updateUri.unit.test.ts index e1c718cf..5ef5dfff 100644 --- a/src/test/features/projectManager.updateUri.unit.test.ts +++ b/src/test/features/projectManager.updateUri.unit.test.ts @@ -14,7 +14,7 @@ suite('Project Manager Update URI tests', () => { projectManager.dispose(); }); - test('updateProjectUri should update existing project URI', () => { + test('updateProjectUri should update existing project URI', async () => { const oldUri = Uri.file('/path/to/old/project'); const newUri = Uri.file('/path/to/new/project'); @@ -36,7 +36,7 @@ suite('Project Manager Update URI tests', () => { assert.equal(oldProject.uri.fsPath, oldUri.fsPath, 'Old URI should match'); // Update the project URI - projectManager.modifyProject(oldUri, 'project', newUri); + await projectManager.modifyProject(oldUri, 'project', newUri); // Verify project no longer exists with old URI const oldProjectAfterUpdate = projectManager.get(oldUri); @@ -57,8 +57,8 @@ suite('Project Manager Update URI tests', () => { // Try to update a project that doesn't exist // This should not throw an error - assert.doesNotThrow(() => { - projectManager.modifyProject(oldUri, 'project', newUri); + assert.doesNotThrow(async () => { + await projectManager.modifyProject(oldUri, 'project', newUri); }, 'Should handle non-existent project gracefully'); // Verify no project was created