From 085706e0cdd569f36f36875fb6698a197c46ed11 Mon Sep 17 00:00:00 2001 From: quantonganh Date: Mon, 14 Aug 2023 20:46:06 +0700 Subject: Include completions for git-ignored files in debugger prompt (#7936) --- helix-term/src/commands/dap.rs | 8 ++++++-- helix-term/src/ui/mod.rs | 28 +++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 5 deletions(-) (limited to 'helix-term') diff --git a/helix-term/src/commands/dap.rs b/helix-term/src/commands/dap.rs index e26dc08d..cc013d1e 100644 --- a/helix-term/src/commands/dap.rs +++ b/helix-term/src/commands/dap.rs @@ -339,8 +339,12 @@ fn debug_parameter_prompt( .to_owned(); let completer = match field_type { - "filename" => ui::completers::filename, - "directory" => ui::completers::directory, + "filename" => |editor: &Editor, input: &str| { + ui::completers::filename_with_git_ignore(editor, input, false) + }, + "directory" => |editor: &Editor, input: &str| { + ui::completers::directory_with_git_ignore(editor, input, false) + }, _ => ui::completers::none, }; diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index 215794e3..2d15fb32 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -345,7 +345,15 @@ pub mod completers { } pub fn filename(editor: &Editor, input: &str) -> Vec { - filename_impl(editor, input, |entry| { + filename_with_git_ignore(editor, input, true) + } + + pub fn filename_with_git_ignore( + editor: &Editor, + input: &str, + git_ignore: bool, + ) -> Vec { + filename_impl(editor, input, git_ignore, |entry| { let is_dir = entry.file_type().map_or(false, |entry| entry.is_dir()); if is_dir { @@ -416,7 +424,15 @@ pub mod completers { } pub fn directory(editor: &Editor, input: &str) -> Vec { - filename_impl(editor, input, |entry| { + directory_with_git_ignore(editor, input, true) + } + + pub fn directory_with_git_ignore( + editor: &Editor, + input: &str, + git_ignore: bool, + ) -> Vec { + filename_impl(editor, input, git_ignore, |entry| { let is_dir = entry.file_type().map_or(false, |entry| entry.is_dir()); if is_dir { @@ -439,7 +455,12 @@ pub mod completers { } // TODO: we could return an iter/lazy thing so it can fetch as many as it needs. - fn filename_impl(_editor: &Editor, input: &str, filter_fn: F) -> Vec + fn filename_impl( + _editor: &Editor, + input: &str, + git_ignore: bool, + filter_fn: F, + ) -> Vec where F: Fn(&ignore::DirEntry) -> FileMatch, { @@ -482,6 +503,7 @@ pub mod completers { let mut files: Vec<_> = WalkBuilder::new(&dir) .hidden(false) .follow_links(false) // We're scanning over depth 1 + .git_ignore(git_ignore) .max_depth(Some(1)) .build() .filter_map(|file| { -- cgit v1.2.3-70-g09d2