mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 06:03:58 +00:00
Don't emit current dir as cwd for runnables
This commit is contained in:
parent
3d7ee9b4ea
commit
8f69d98214
2 changed files with 22 additions and 17 deletions
|
@ -897,21 +897,23 @@ pub(crate) fn handle_runnables(
|
|||
Some(TargetSpec::ProjectJson(_)) => {}
|
||||
None => {
|
||||
if !snap.config.linked_or_discovered_projects().is_empty() {
|
||||
let mut cargo_args = vec!["check".to_owned(), "--workspace".to_owned()];
|
||||
cargo_args.extend(config.cargo_extra_args.iter().cloned());
|
||||
res.push(lsp_ext::Runnable {
|
||||
label: "cargo check --workspace".to_owned(),
|
||||
location: None,
|
||||
kind: lsp_ext::RunnableKind::Cargo,
|
||||
args: lsp_ext::RunnableArgs::Cargo(lsp_ext::CargoRunnableArgs {
|
||||
workspace_root: None,
|
||||
cwd: ".".into(),
|
||||
override_cargo: config.override_cargo,
|
||||
cargo_args,
|
||||
executable_args: Vec::new(),
|
||||
environment: Default::default(),
|
||||
}),
|
||||
});
|
||||
if let Some(path) = snap.file_id_to_file_path(file_id).parent() {
|
||||
let mut cargo_args = vec!["check".to_owned(), "--workspace".to_owned()];
|
||||
cargo_args.extend(config.cargo_extra_args.iter().cloned());
|
||||
res.push(lsp_ext::Runnable {
|
||||
label: "cargo check --workspace".to_owned(),
|
||||
location: None,
|
||||
kind: lsp_ext::RunnableKind::Cargo,
|
||||
args: lsp_ext::RunnableArgs::Cargo(lsp_ext::CargoRunnableArgs {
|
||||
workspace_root: None,
|
||||
cwd: path.as_path().unwrap().to_path_buf().into(),
|
||||
override_cargo: config.override_cargo,
|
||||
cargo_args,
|
||||
executable_args: Vec::new(),
|
||||
environment: Default::default(),
|
||||
}),
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ use ide::{
|
|||
};
|
||||
use ide_db::{rust_doc::format_docs, FxHasher};
|
||||
use itertools::Itertools;
|
||||
use paths::{Utf8Component, Utf8PathBuf, Utf8Prefix};
|
||||
use paths::{Utf8Component, Utf8Prefix};
|
||||
use semver::VersionReq;
|
||||
use serde_json::to_value;
|
||||
use vfs::AbsPath;
|
||||
|
@ -1419,6 +1419,9 @@ pub(crate) fn runnable(
|
|||
}
|
||||
}
|
||||
None => {
|
||||
let Some(path) = snap.file_id_to_file_path(runnable.nav.file_id).parent() else {
|
||||
return Ok(None);
|
||||
};
|
||||
let (cargo_args, executable_args) =
|
||||
CargoTargetSpec::runnable_args(snap, None, &runnable.kind, &runnable.cfg);
|
||||
|
||||
|
@ -1433,7 +1436,7 @@ pub(crate) fn runnable(
|
|||
workspace_root: None,
|
||||
override_cargo: config.override_cargo,
|
||||
cargo_args,
|
||||
cwd: Utf8PathBuf::from("."),
|
||||
cwd: path.as_path().unwrap().to_path_buf().into(),
|
||||
executable_args,
|
||||
environment: Default::default(),
|
||||
}),
|
||||
|
|
Loading…
Reference in a new issue