From 56951662c0a82ee2f96769ac89121b67280957a6 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 94013899cc4e..098164cd3f11 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2867,8 +2867,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 } };