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]);