diff --git a/package.json b/package.json index b30786c1..f00f5fc9 100644 --- a/package.json +++ b/package.json @@ -224,7 +224,7 @@ "rust-client.enableMultiProjectSetup": { "type": "boolean", "default": false, - "description": "Allow multiple projects in the same folder, along with remove the constraint that the cargo.toml must be located at the root. (Experimental: might not work for certain setups)" + "description": "Allow multiple projects in the same folder, along with removing the constraint that the cargo.toml must be located at the root. (Experimental: might not work for certain setups)" }, "rust.sysroot": { "type": [ diff --git a/src/extension.ts b/src/extension.ts index d66a2912..21cab973 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -207,9 +207,16 @@ class ClientWorkspace { return this.makeRlsProcess(); }; + // Something else is put front of files when pattern matching that prevents the windows version from picking up the files + // This should be safe as the uri is a absolute path that includes the drive + colon + // i.e. a pattern would become "**/c:/some/path**" and since colon is reserved only the root can ever contain it. + const isWin = process.platform === 'win32'; + const windowsHack = isWin ? '**' : ''; + const pattern = this.config.multiProjectEnabled - ? `${this.folder.uri.path}/**` + ? `${windowsHack}${this.folder.uri.path}/**` : undefined; + const collectionName = this.config.multiProjectEnabled ? `rust ${this.folder.uri.toString()}` : 'rust'; @@ -309,6 +316,7 @@ class ClientWorkspace { const ws = multiProjectEnabled && activeWorkspace ? activeWorkspace : this; await ws.stop(); + commandsRegistered = true; return ws.start(context); }); this.disposables.push(restartServer); diff --git a/src/tasks.ts b/src/tasks.ts index 375f2ac2..24d1fe7c 100644 --- a/src/tasks.ts +++ b/src/tasks.ts @@ -78,7 +78,11 @@ function detectCargoTasks(target: WorkspaceFolder): Task[] { .map(({ subcommand, group }) => ({ definition: { subcommand, type: TASK_TYPE }, label: `cargo ${subcommand}`, - execution: createShellExecution({ command: 'cargo', args: [subcommand] }), + execution: createShellExecution({ + command: 'cargo', + args: [subcommand], + cwd: target.uri.fsPath, + }), group, problemMatchers: ['$rustc'], })) diff --git a/src/workspace_util.ts b/src/workspace_util.ts index eb1961b9..d96a697b 100644 --- a/src/workspace_util.ts +++ b/src/workspace_util.ts @@ -8,7 +8,7 @@ export function nearestParentWorkspace( filePath: string, ): WorkspaceFolder { // check that the workspace folder already contains the "Cargo.toml" - const workspaceRoot = path.parse(curWorkspace.uri.fsPath).dir; + const workspaceRoot = curWorkspace.uri.fsPath; const rootManifest = path.join(workspaceRoot, 'Cargo.toml'); if (fs.existsSync(rootManifest)) { return curWorkspace; @@ -25,8 +25,8 @@ export function nearestParentWorkspace( break; } - // break in case the strip folder has not changed - if (workspaceRoot === path.parse(current).dir) { + // break in case the strip folder reached the workspace root + if (workspaceRoot === current) { break; } @@ -34,7 +34,11 @@ export function nearestParentWorkspace( const cargoPath = path.join(current, 'Cargo.toml'); if (fs.existsSync(cargoPath)) { // ghetto change the uri on Workspace folder to make vscode think it's located elsewhere - return { ...curWorkspace, uri: Uri.parse(current) }; + return { + ...curWorkspace, + name: path.basename(current), + uri: Uri.file(current), + }; } }