From 544aa9871875065256bac1600da6480cf96e8508 Mon Sep 17 00:00:00 2001 From: Jinbo Wang Date: Fri, 19 Apr 2024 14:38:07 +0800 Subject: [PATCH] Fix #828: creates file watcher with trailing slash causes problems for other extensions --- src/syncHandler.ts | 2 +- src/views/dependencyDataProvider.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/syncHandler.ts b/src/syncHandler.ts index 031aa190..d6d247c0 100644 --- a/src/syncHandler.ts +++ b/src/syncHandler.ts @@ -51,7 +51,7 @@ class SyncHandler implements Disposable { try { const uris = await this.getWatchingUris(); for (const uri of uris) { - const normalizedPath: string = uri.fsPath; + const normalizedPath: string = uri.fsPath?.replace(/[\\\/]+$/, ""); // remove trailing slashes const pattern: RelativePattern = new RelativePattern(normalizedPath, "**/*"); const watcher: FileSystemWatcher = workspace.createFileSystemWatcher(pattern); this.disposables.push(watcher); diff --git a/src/views/dependencyDataProvider.ts b/src/views/dependencyDataProvider.ts index 72c4cf55..dd0bd05b 100644 --- a/src/views/dependencyDataProvider.ts +++ b/src/views/dependencyDataProvider.ts @@ -64,7 +64,7 @@ export class DependencyDataProvider implements TreeDataProvider { window.showErrorMessage("The URI of the project is not available, you can try to trigger the command 'Java: Reload Project' from Command Palette."); return; } - const pattern: RelativePattern = new RelativePattern(Uri.parse(node.uri).fsPath, "{pom.xml,*.gradle}"); + const pattern: RelativePattern = new RelativePattern(Uri.parse(node.uri).fsPath?.replace(/[\\\/]+$/, ""), "{pom.xml,*.gradle}"); const uris: Uri[] = await workspace.findFiles(pattern, null /*exclude*/, 1 /*maxResults*/); if (uris.length >= 1) { commands.executeCommand(Commands.JAVA_PROJECT_CONFIGURATION_UPDATE, uris[0]);