|
|
@ -345,7 +345,15 @@ pub mod completers {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn filename(editor: &Editor, input: &str) -> Vec<Completion> {
|
|
|
|
pub fn filename(editor: &Editor, input: &str) -> Vec<Completion> {
|
|
|
|
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<Completion> {
|
|
|
|
|
|
|
|
filename_impl(editor, input, git_ignore, |entry| {
|
|
|
|
let is_dir = entry.file_type().map_or(false, |entry| entry.is_dir());
|
|
|
|
let is_dir = entry.file_type().map_or(false, |entry| entry.is_dir());
|
|
|
|
|
|
|
|
|
|
|
|
if is_dir {
|
|
|
|
if is_dir {
|
|
|
@ -416,7 +424,15 @@ pub mod completers {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn directory(editor: &Editor, input: &str) -> Vec<Completion> {
|
|
|
|
pub fn directory(editor: &Editor, input: &str) -> Vec<Completion> {
|
|
|
|
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<Completion> {
|
|
|
|
|
|
|
|
filename_impl(editor, input, git_ignore, |entry| {
|
|
|
|
let is_dir = entry.file_type().map_or(false, |entry| entry.is_dir());
|
|
|
|
let is_dir = entry.file_type().map_or(false, |entry| entry.is_dir());
|
|
|
|
|
|
|
|
|
|
|
|
if 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.
|
|
|
|
// TODO: we could return an iter/lazy thing so it can fetch as many as it needs.
|
|
|
|
fn filename_impl<F>(_editor: &Editor, input: &str, filter_fn: F) -> Vec<Completion>
|
|
|
|
fn filename_impl<F>(
|
|
|
|
|
|
|
|
_editor: &Editor,
|
|
|
|
|
|
|
|
input: &str,
|
|
|
|
|
|
|
|
git_ignore: bool,
|
|
|
|
|
|
|
|
filter_fn: F,
|
|
|
|
|
|
|
|
) -> Vec<Completion>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
F: Fn(&ignore::DirEntry) -> FileMatch,
|
|
|
|
F: Fn(&ignore::DirEntry) -> FileMatch,
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -482,6 +503,7 @@ pub mod completers {
|
|
|
|
let mut files: Vec<_> = WalkBuilder::new(&dir)
|
|
|
|
let mut files: Vec<_> = WalkBuilder::new(&dir)
|
|
|
|
.hidden(false)
|
|
|
|
.hidden(false)
|
|
|
|
.follow_links(false) // We're scanning over depth 1
|
|
|
|
.follow_links(false) // We're scanning over depth 1
|
|
|
|
|
|
|
|
.git_ignore(git_ignore)
|
|
|
|
.max_depth(Some(1))
|
|
|
|
.max_depth(Some(1))
|
|
|
|
.build()
|
|
|
|
.build()
|
|
|
|
.filter_map(|file| {
|
|
|
|
.filter_map(|file| {
|
|
|
|