Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: :open and splits can now autocomplete ignored files #12418

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6104,7 +6104,7 @@ fn shell_prompt(cx: &mut Context, prompt: Cow<'static, str>, behavior: ShellBeha
cx,
prompt,
Some('|'),
ui::completers::filename,
ui::completers::filename_including_git_ignore,
move |cx, input: &str, event: PromptEvent| {
if event != PromptEvent::Validate {
return;
Expand Down
24 changes: 12 additions & 12 deletions helix-term/src/commands/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2443,7 +2443,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
aliases: &["o", "edit", "e"],
doc: "Open a file from disk into the current view.",
fun: open,
signature: CommandSignature::all(completers::filename),
signature: CommandSignature::all(completers::filename_excluding_git_ignore),
},
TypableCommand {
name: "buffer-close",
Expand Down Expand Up @@ -2506,28 +2506,28 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
aliases: &["w"],
doc: "Write changes to disk. Accepts an optional path (:write some/path.txt)",
fun: write,
signature: CommandSignature::positional(&[completers::filename]),
signature: CommandSignature::positional(&[completers::filename_including_git_ignore]),
},
TypableCommand {
name: "write!",
aliases: &["w!"],
doc: "Force write changes to disk creating necessary subdirectories. Accepts an optional path (:write! some/path.txt)",
fun: force_write,
signature: CommandSignature::positional(&[completers::filename]),
signature: CommandSignature::positional(&[completers::filename_including_git_ignore]),
},
TypableCommand {
name: "write-buffer-close",
aliases: &["wbc"],
doc: "Write changes to disk and closes the buffer. Accepts an optional path (:write-buffer-close some/path.txt)",
fun: write_buffer_close,
signature: CommandSignature::positional(&[completers::filename]),
signature: CommandSignature::positional(&[completers::filename_including_git_ignore]),
},
TypableCommand {
name: "write-buffer-close!",
aliases: &["wbc!"],
doc: "Force write changes to disk creating necessary subdirectories and closes the buffer. Accepts an optional path (:write-buffer-close! some/path.txt)",
fun: force_write_buffer_close,
signature: CommandSignature::positional(&[completers::filename]),
signature: CommandSignature::positional(&[completers::filename_including_git_ignore]),
},
TypableCommand {
name: "new",
Expand Down Expand Up @@ -2579,14 +2579,14 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
aliases: &["wq", "x"],
doc: "Write changes to disk and close the current view. Accepts an optional path (:wq some/path.txt)",
fun: write_quit,
signature: CommandSignature::positional(&[completers::filename]),
signature: CommandSignature::positional(&[completers::filename_including_git_ignore]),
},
TypableCommand {
name: "write-quit!",
aliases: &["wq!", "x!"],
doc: "Write changes to disk and close the current view forcefully. Accepts an optional path (:wq! some/path.txt)",
fun: force_write_quit,
signature: CommandSignature::positional(&[completers::filename]),
signature: CommandSignature::positional(&[completers::filename_including_git_ignore]),
},
TypableCommand {
name: "write-all",
Expand Down Expand Up @@ -2845,7 +2845,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
aliases: &["vs"],
doc: "Open the file in a vertical split.",
fun: vsplit,
signature: CommandSignature::all(completers::filename)
signature: CommandSignature::all(completers::filename_excluding_git_ignore)
},
TypableCommand {
name: "vsplit-new",
Expand All @@ -2859,7 +2859,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
aliases: &["hs", "sp"],
doc: "Open the file in a horizontal split.",
fun: hsplit,
signature: CommandSignature::all(completers::filename)
signature: CommandSignature::all(completers::filename_excluding_git_ignore)
},
TypableCommand {
name: "hsplit-new",
Expand Down Expand Up @@ -3000,7 +3000,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
aliases: &["sh"],
doc: "Run a shell command",
fun: run_shell_command,
signature: CommandSignature::all(completers::filename)
signature: CommandSignature::all(completers::filename_including_git_ignore)
},
TypableCommand {
name: "reset-diff-change",
Expand Down Expand Up @@ -3028,7 +3028,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
aliases: &["mv"],
doc: "Move the current buffer and its corresponding file to a different path",
fun: move_buffer,
signature: CommandSignature::positional(&[completers::filename]),
signature: CommandSignature::positional(&[completers::filename_including_git_ignore]),
},
TypableCommand {
name: "yank-diagnostic",
Expand All @@ -3042,7 +3042,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
aliases: &["r"],
doc: "Load a file into buffer",
fun: read,
signature: CommandSignature::positional(&[completers::filename]),
signature: CommandSignature::positional(&[completers::filename_including_git_ignore]),
},
];

Expand Down
6 changes: 5 additions & 1 deletion helix-term/src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,14 @@ pub mod completers {
.collect()
}

pub fn filename(editor: &Editor, input: &str) -> Vec<Completion> {
pub fn filename_including_git_ignore(editor: &Editor, input: &str) -> Vec<Completion> {
filename_with_git_ignore(editor, input, true)
}

pub fn filename_excluding_git_ignore(editor: &Editor, input: &str) -> Vec<Completion> {
filename_with_git_ignore(editor, input, false)
}

pub fn filename_with_git_ignore(
editor: &Editor,
input: &str,
Expand Down
Loading