aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs23
1 files changed, 19 insertions, 4 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index ae715887..47b1a175 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -2080,8 +2080,12 @@ fn global_search(cx: &mut Context) {
.binary_detection(BinaryDetection::quit(b'\x00'))
.build();
- let search_root = std::env::current_dir()
- .expect("Global search error: Failed to get current dir");
+ let search_root = helix_loader::current_working_dir();
+ if !search_root.exists() {
+ editor.set_error("Current working directory does not exist");
+ return;
+ }
+
let dedup_symlinks = file_picker_config.deduplicate_links;
let absolute_root = search_root
.canonicalize()
@@ -2173,7 +2177,9 @@ fn global_search(cx: &mut Context) {
let call: job::Callback = Callback::EditorCompositor(Box::new(
move |editor: &mut Editor, compositor: &mut Compositor| {
if all_matches.is_empty() {
- editor.set_status("No matches found");
+ if !editor.is_err() {
+ editor.set_status("No matches found");
+ }
return;
}
@@ -2518,6 +2524,10 @@ fn append_mode(cx: &mut Context) {
fn file_picker(cx: &mut Context) {
let root = find_workspace().0;
+ if !root.exists() {
+ cx.editor.set_error("Workspace directory does not exist");
+ return;
+ }
let picker = ui::file_picker(root, &cx.editor.config());
cx.push_layer(Box::new(overlaid(picker)));
}
@@ -2539,7 +2549,12 @@ fn file_picker_in_current_buffer_directory(cx: &mut Context) {
cx.push_layer(Box::new(overlaid(picker)));
}
fn file_picker_in_current_directory(cx: &mut Context) {
- let cwd = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("./"));
+ let cwd = helix_loader::current_working_dir();
+ if !cwd.exists() {
+ cx.editor
+ .set_error("Current working directory does not exist");
+ return;
+ }
let picker = ui::file_picker(cwd, &cx.editor.config());
cx.push_layer(Box::new(overlaid(picker)));
}