From 7e58404172cd8ca9c63f986f9551397b67c5e85f 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 c4f99ee3b..7decc5777 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2957,8 +2957,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 } };