on master help sign in
Include completions for git-ignored files in debugger prompt (#7936)
commit085706e0cdd569f36f36875fb6698a197c46ed11 authorquantonganh <quantonganh@gmail.com> dateMon 14 Aug 2023, 20:46 (3 years ago) parentd6bb109
2 files changed+31−5
helix-term/src/commands/dap.rs+6−2 helix-term/src/ui/mod.rs+25−3
helix-term/src/commands/dap.rs+6−2
@@ -339,8 +339,12 @@ fn debug_parameter_prompt(
339339 .to_owned();
340340
341341 let completer = match field_type {
342− "filename" => ui::completers::filename,
343− "directory" => ui::completers::directory,
342+ "filename" => |editor: &Editor, input: &str| {
343+ ui::completers::filename_with_git_ignore(editor, input, false)
344+ },
345+ "directory" => |editor: &Editor, input: &str| {
346+ ui::completers::directory_with_git_ignore(editor, input, false)
347+ },
344348 _ => ui::completers::none,
345349 };
346350
helix-term/src/ui/mod.rs+25−3
@@ -345,7 +345,15 @@ pub mod completers {
345345 }
346346
347347 pub fn filename(editor: &Editor, input: &str) -> Vec<Completion> {
348− filename_impl(editor, input, |entry| {
348+ filename_with_git_ignore(editor, input, true)
349+ }
350+
351+ pub fn filename_with_git_ignore(
352+ editor: &Editor,
353+ input: &str,
354+ git_ignore: bool,
355+ ) -> Vec<Completion> {
356+ filename_impl(editor, input, git_ignore, |entry| {
349357 let is_dir = entry.file_type().map_or(false, |entry| entry.is_dir());
350358
351359 if is_dir {
@@ -416,7 +424,15 @@ pub mod completers {
416424 }
417425
418426 pub fn directory(editor: &Editor, input: &str) -> Vec<Completion> {
419− filename_impl(editor, input, |entry| {
427+ directory_with_git_ignore(editor, input, true)
428+ }
429+
430+ pub fn directory_with_git_ignore(
431+ editor: &Editor,
432+ input: &str,
433+ git_ignore: bool,
434+ ) -> Vec<Completion> {
435+ filename_impl(editor, input, git_ignore, |entry| {
420436 let is_dir = entry.file_type().map_or(false, |entry| entry.is_dir());
421437
422438 if is_dir {
@@ -439,7 +455,12 @@ pub mod completers {
439455 }
440456
441457 // TODO: we could return an iter/lazy thing so it can fetch as many as it needs.
442− fn filename_impl<F>(_editor: &Editor, input: &str, filter_fn: F) -> Vec<Completion>
458+ fn filename_impl<F>(
459+ _editor: &Editor,
460+ input: &str,
461+ git_ignore: bool,
462+ filter_fn: F,
463+ ) -> Vec<Completion>
443464 where
444465 F: Fn(&ignore::DirEntry) -> FileMatch,
445466 {
@@ -482,6 +503,7 @@ pub mod completers {
482503 let mut files: Vec<_> = WalkBuilder::new(&dir)
483504 .hidden(false)
484505 .follow_links(false) // We're scanning over depth 1
506+ .git_ignore(git_ignore)
485507 .max_depth(Some(1))
486508 .build()
487509 .filter_map(|file| {