diff --git a/docs/image_previews.md b/docs/image_previews.md index 41e05e845..40c074f98 100644 --- a/docs/image_previews.md +++ b/docs/image_previews.md @@ -265,7 +265,7 @@ case "$mimetype" in esac ``` -`~/.config/joshuto/on_preview_removed.sh`: +`~/.config/joshuto/on_preview_removed`: ```shell #!/usr/bin/env bash diff --git a/src/key_command/impl_from_str.rs b/src/key_command/impl_from_str.rs index b88af8cd6..d684bf983 100644 --- a/src/key_command/impl_from_str.rs +++ b/src/key_command/impl_from_str.rs @@ -248,7 +248,6 @@ impl std::str::FromStr for Command { } else if command == CMD_DELETE_FILES { let (mut permanently, mut background) = (false, false); for arg in arg.split_whitespace() { - eprintln!("arg: {:?}", arg); match arg { "--background=true" => background = true, "--background=false" => background = false, diff --git a/src/ui/views/tui_textfield.rs b/src/ui/views/tui_textfield.rs index b080710bd..57929eef4 100644 --- a/src/ui/views/tui_textfield.rs +++ b/src/ui/views/tui_textfield.rs @@ -215,6 +215,10 @@ impl<'a> TuiTextField<'a> { let _ = terminal.hide_cursor(); return None; } + Key::Ctrl('c') => { + let _ = terminal.hide_cursor(); + return None; + } Key::Char('\t') => autocomplete( &mut line_buffer, &mut completion_tracker, @@ -313,16 +317,19 @@ fn autocomplete( if let Some(ref mut ct) = completion_tracker { ct.index = if reversed { ct.index.checked_sub(1).unwrap_or(ct.candidates.len() - 1) - } else if ct.index + 1 < ct.candidates.len() { - ct.index + 1 } else { - ct.index + (ct.index + 1) % ct.candidates.len() }; let candidate = &ct.candidates[ct.index]; - completer.update(line_buffer, ct.pos, candidate.display()); + completer.update(line_buffer, ct.pos, candidate.replacement()); } else if let Some((pos, mut candidates)) = get_candidates(completer, line_buffer) { if !candidates.is_empty() { + if candidates.len() == 1 && candidates[0].replacement().ends_with('/') { + completer.update(line_buffer, pos, &candidates[0].replacement()); + return false; + } + candidates.sort_by(|x, y| { x.display() .partial_cmp(y.display()) @@ -330,7 +337,7 @@ fn autocomplete( }); let first_idx = if reversed { candidates.len() - 1 } else { 0 }; - let first = candidates[first_idx].display().to_string(); + let first = candidates[first_idx].replacement().to_string(); let mut ct = CompletionTracker::new(pos, candidates, String::from(line_buffer.as_str()));