mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
fix: when running the "discoverProjectCommand", use the Rust file's
parent directory instead of the workspace folder.
This commit is contained in:
parent
51d5862caf
commit
b99c129b74
2 changed files with 15 additions and 12 deletions
|
@ -761,12 +761,13 @@ export function addProject(ctx: CtxInit): Cmd {
|
||||||
}
|
}
|
||||||
|
|
||||||
const workspaces: JsonProject[] = await Promise.all(
|
const workspaces: JsonProject[] = await Promise.all(
|
||||||
vscode.workspace.workspaceFolders!.map(async (folder): Promise<JsonProject> => {
|
vscode.workspace.textDocuments
|
||||||
const rustDocuments = vscode.workspace.textDocuments.filter(isRustDocument);
|
.filter(isRustDocument)
|
||||||
return discoverWorkspace(rustDocuments, discoverProjectCommand, {
|
.map(async (file): Promise<JsonProject> => {
|
||||||
cwd: folder.uri.fsPath,
|
return discoverWorkspace([file], discoverProjectCommand, {
|
||||||
});
|
cwd: path.dirname(file.uri.fsPath),
|
||||||
})
|
});
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
ctx.addToDiscoveredWorkspaces(workspaces);
|
ctx.addToDiscoveredWorkspaces(workspaces);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import * as vscode from "vscode";
|
import * as vscode from "vscode";
|
||||||
import * as lc from "vscode-languageclient/node";
|
import * as lc from "vscode-languageclient/node";
|
||||||
import * as ra from "./lsp_ext";
|
import * as ra from "./lsp_ext";
|
||||||
|
import * as path from "path";
|
||||||
|
|
||||||
import { Config, prepareVSCodeConfig } from "./config";
|
import { Config, prepareVSCodeConfig } from "./config";
|
||||||
import { createClient } from "./client";
|
import { createClient } from "./client";
|
||||||
|
@ -192,12 +193,13 @@ export class Ctx {
|
||||||
const discoverProjectCommand = this.config.discoverProjectCommand;
|
const discoverProjectCommand = this.config.discoverProjectCommand;
|
||||||
if (discoverProjectCommand) {
|
if (discoverProjectCommand) {
|
||||||
const workspaces: JsonProject[] = await Promise.all(
|
const workspaces: JsonProject[] = await Promise.all(
|
||||||
vscode.workspace.workspaceFolders!.map(async (folder): Promise<JsonProject> => {
|
vscode.workspace.textDocuments
|
||||||
const rustDocuments = vscode.workspace.textDocuments.filter(isRustDocument);
|
.filter(isRustDocument)
|
||||||
return discoverWorkspace(rustDocuments, discoverProjectCommand, {
|
.map(async (file): Promise<JsonProject> => {
|
||||||
cwd: folder.uri.fsPath,
|
return discoverWorkspace([file], discoverProjectCommand, {
|
||||||
});
|
cwd: path.dirname(file.uri.fsPath),
|
||||||
})
|
});
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
this.addToDiscoveredWorkspaces(workspaces);
|
this.addToDiscoveredWorkspaces(workspaces);
|
||||||
|
|
Loading…
Reference in a new issue