aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/commands')
-rw-r--r--helix-term/src/commands/dap.rs2
-rw-r--r--helix-term/src/commands/lsp.rs2
-rw-r--r--helix-term/src/commands/typed.rs18
3 files changed, 12 insertions, 10 deletions
diff --git a/helix-term/src/commands/dap.rs b/helix-term/src/commands/dap.rs
index 70a5ec21..e26dc08d 100644
--- a/helix-term/src/commands/dap.rs
+++ b/helix-term/src/commands/dap.rs
@@ -217,7 +217,7 @@ pub fn dap_start_impl(
}
}
- args.insert("cwd", to_value(std::env::current_dir().unwrap())?);
+ args.insert("cwd", to_value(helix_loader::current_working_dir())?);
let args = to_value(args).unwrap();
diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs
index 55153648..145bddd0 100644
--- a/helix-term/src/commands/lsp.rs
+++ b/helix-term/src/commands/lsp.rs
@@ -1033,7 +1033,7 @@ fn goto_impl(
locations: Vec<lsp::Location>,
offset_encoding: OffsetEncoding,
) {
- let cwdir = std::env::current_dir().unwrap_or_default();
+ let cwdir = helix_loader::current_working_dir();
match locations.as_slice() {
[location] => {
diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs
index 94cc33f0..dfc71dfd 100644
--- a/helix-term/src/commands/typed.rs
+++ b/helix-term/src/commands/typed.rs
@@ -1093,14 +1093,11 @@ fn change_current_directory(
.as_ref(),
);
- if let Err(e) = std::env::set_current_dir(dir) {
- bail!("Couldn't change the current working directory: {}", e);
- }
+ helix_loader::set_current_working_dir(dir)?;
- let cwd = std::env::current_dir().context("Couldn't get the new working directory")?;
cx.editor.set_status(format!(
"Current working directory is now {}",
- cwd.display()
+ helix_loader::current_working_dir().display()
));
Ok(())
}
@@ -1114,9 +1111,14 @@ fn show_current_directory(
return Ok(());
}
- let cwd = std::env::current_dir().context("Couldn't get the new working directory")?;
- cx.editor
- .set_status(format!("Current working directory is {}", cwd.display()));
+ let cwd = helix_loader::current_working_dir();
+ let message = format!("Current working directory is {}", cwd.display());
+
+ if cwd.exists() {
+ cx.editor.set_status(message);
+ } else {
+ cx.editor.set_error(format!("{} (deleted)", message));
+ }
Ok(())
}