From ff833b79e7e6113fd30ee1a7b4ee1a1bd8ea3f5e Mon Sep 17 00:00:00 2001 From: Denys Rybalka Date: Fri, 13 Sep 2024 13:44:30 +0200 Subject: [PATCH] Open file browser in cwd when no buffer path --- helix-term/src/commands.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 6c5c81e5..e2058751 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2995,8 +2995,14 @@ fn file_browser(cx: &mut Context) { let path = match doc_dir { Some(path) => path, None => { - cx.editor.set_error("Current buffer has no path or parent"); - return; + let cwd = helix_stdx::env::current_working_dir(); + if !cwd.exists() { + cx.editor.set_error( + "Current buffer has no parent and current working directory does not exist", + ); + return; + } + cwd } };