on master help sign in
Include completions for git-ignored files in debugger prompt (#7936)
085706equantonganh
helix-term/src/commands/dap.rs+6−2
@@ -339,8 +339,12 @@ fn debug_parameter_prompt(
339 .to_owned();
339 .to_owned();
340
340
341 let completer = match field_type {
341 let completer = match field_type {
342− "filename" => ui::completers::filename,
342+ "filename" => |editor: &Editor, input: &str| {
343− "directory" => ui::completers::directory,
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+ },
344 _ => ui::completers::none,
348 _ => ui::completers::none,
345 };
349 };
346
350
helix-term/src/ui/mod.rs+25−3
@@ -345,7 +345,15 @@ pub mod completers {
345 }
345 }
346
346
347 pub fn filename(editor: &Editor, input: &str) -> Vec<Completion> {
347 pub fn filename(editor: &Editor, input: &str) -> Vec<Completion> {
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> {
348− filename_impl(editor, input, |entry| {
356+ filename_impl(editor, input, git_ignore, |entry| {
349 let is_dir = entry.file_type().map_or(false, |entry| entry.is_dir());
357 let is_dir = entry.file_type().map_or(false, |entry| entry.is_dir());
350
358
351 if is_dir {
359 if is_dir {
@@ -416,7 +424,15 @@ pub mod completers {
416 }
424 }
417
425
418 pub fn directory(editor: &Editor, input: &str) -> Vec<Completion> {
426 pub fn directory(editor: &Editor, input: &str) -> Vec<Completion> {
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> {
419− filename_impl(editor, input, |entry| {
435+ filename_impl(editor, input, git_ignore, |entry| {
420 let is_dir = entry.file_type().map_or(false, |entry| entry.is_dir());
436 let is_dir = entry.file_type().map_or(false, |entry| entry.is_dir());
421
437
422 if is_dir {
438 if is_dir {
@@ -439,7 +455,12 @@ pub mod completers {
439 }
455 }
440
456
441 // TODO: we could return an iter/lazy thing so it can fetch as many as it needs.
457 // 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>
443 where
464 where
444 F: Fn(&ignore::DirEntry) -> FileMatch,
465 F: Fn(&ignore::DirEntry) -> FileMatch,
445 {
466 {
@@ -482,6 +503,7 @@ pub mod completers {
482 let mut files: Vec<_> = WalkBuilder::new(&dir)
503 let mut files: Vec<_> = WalkBuilder::new(&dir)
483 .hidden(false)
504 .hidden(false)
484 .follow_links(false) // We're scanning over depth 1
505 .follow_links(false) // We're scanning over depth 1
506+ .git_ignore(git_ignore)
485 .max_depth(Some(1))
507 .max_depth(Some(1))
486 .build()
508 .build()
487 .filter_map(|file| {
509 .filter_map(|file| {