From 562874a720678a238966c69f413cb3d691f74c66 Mon Sep 17 00:00:00 2001 From: gavynriebau Date: Sun, 10 Apr 2022 10:30:09 +0800 Subject: Add command for picking files from CWD (#1600) The `file_picker_at_current_directory` command opens the file picker at the current working directory (CWD). This can be useful when paired with the built-in `:cd` command which changes the CWD. It has been mapped to `space F` by default.--- helix-term/src/commands.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'helix-term/src/commands.rs') diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 3757912a..886ee62d 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -259,6 +259,7 @@ impl MappableCommand { append_mode, "Insert after selection (append)", command_mode, "Enter command mode", file_picker, "Open file picker", + file_picker_in_current_directory, "Open file picker at current working directory", code_action, "Perform code action", buffer_picker, "Open buffer picker", symbol_picker, "Open symbol picker", @@ -2047,6 +2048,12 @@ fn file_picker(cx: &mut Context) { cx.push_layer(Box::new(overlayed(picker))); } +fn file_picker_in_current_directory(cx: &mut Context) { + let cwd = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("./")); + let picker = ui::file_picker(cwd, &cx.editor.config()); + cx.push_layer(Box::new(picker)); +} + fn buffer_picker(cx: &mut Context) { let current = view!(cx.editor).doc; -- cgit v1.2.3-70-g09d2