feat: input history#3939
Open
OliverGuy wants to merge 17 commits into
Open
Conversation
sxyazi
requested changes
May 7, 2026
Owner
sxyazi
left a comment
There was a problem hiding this comment.
Thanks for the patch! A few change requests:
- INPUT_HISTORY should be changed to a field named
historyonyazi_core::input::Input, i.e. it should belong to the input component, not the input widget. Components are globally unique and meant for holding persistent state, while widgets are created multiple times; this also lets us remove unnecessary locking. yazi-widgets/src/input/actor/history.rsshould likewise be a component action, not a widget action, i.e. it should live underyazi_core::input.- The input widget should have a string ID to distinguish its type, e.g.
"shell"for the input used for shell commands and"search"for the input used for searches, etc. Separating search input and shell history makes more sense and also aligns with Vim's behavior. - Each history type should have a maximum cap to avoid unbounded growth, for now we can hardcode it to
20entries to keep the design simple.
Author
|
Hope this is what you had in mind :) |
sxyazi
requested changes
May 12, 2026
| pub position: Position, | ||
| pub realtime: bool, | ||
| pub completion: bool, | ||
| pub id: String, |
Owner
There was a problem hiding this comment.
Please place id before the existing title, and change its type to SStr
| value: if cwd.kind().is_local() { String::new() } else { EncodeScheme(cwd).to_string() }, | ||
| position: Position::new(YAZI.input.cd_origin, YAZI.input.cd_offset), | ||
| completion: true, | ||
| id: "cd".to_owned(), |
Owner
There was a problem hiding this comment.
Please place id before the existing title, and change its type to SStr
| Self { | ||
| title: YAZI.input.create_title[dir as usize].clone(), | ||
| position: Position::new(YAZI.input.create_origin, YAZI.input.create_offset), | ||
| id: "create".to_owned(), |
| Self { | ||
| title: YAZI.input.rename_title.clone(), | ||
| position: Position::new(YAZI.input.rename_origin, YAZI.input.rename_offset), | ||
| id: "rename".to_owned(), |
| title: YAZI.input.filter_title.clone(), | ||
| position: Position::new(YAZI.input.filter_origin, YAZI.input.filter_offset), | ||
| realtime: true, | ||
| id: "filter".to_owned(), |
|
|
||
| #[derive(Default)] | ||
| pub struct InputHistory { | ||
| entries: std::collections::VecDeque<String>, |
Owner
There was a problem hiding this comment.
Suggested change
| entries: std::collections::VecDeque<String>, | |
| entries: VecDeque<String>, |
| #[derive(Default)] | ||
| pub struct InputHistory { | ||
| entries: std::collections::VecDeque<String>, | ||
| entry_snaps: std::collections::VecDeque<Option<InputSnaps>>, |
Owner
There was a problem hiding this comment.
Suggested change
| entry_snaps: std::collections::VecDeque<Option<InputSnaps>>, | |
| entry_snaps: VecDeque<Option<InputSnaps>>, |
| impl InputHistory { | ||
| pub const fn new() -> Self { | ||
| Self { | ||
| entries: std::collections::VecDeque::new(), |
Owner
There was a problem hiding this comment.
Suggested change
| entries: std::collections::VecDeque::new(), | |
| entries: VecDeque::new(), |
| pub const fn new() -> Self { | ||
| Self { | ||
| entries: std::collections::VecDeque::new(), | ||
| entry_snaps: std::collections::VecDeque::new(), |
Owner
There was a problem hiding this comment.
Suggested change
| entry_snaps: std::collections::VecDeque::new(), | |
| entry_snaps: VecDeque::new(), |
| @@ -0,0 +1,93 @@ | |||
| use std::mem; | |||
Owner
There was a problem hiding this comment.
Please move this file to yazi_core::input
(scope): title
also adds a new InputSnaps method to circumvent private methods
Author
|
The changes should have been addressed, I'll let you mark them as resolved as you review 😃 |
00e4151 to
7a51626
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR resolve?
Resolves #3723
Rationale of this PR
Adds command history to the input widget, similar to shell history navigation.
keymap.tomlviahistory <n>, wherenis a potentially negative integer offset.INPUT_HISTORYthat stores input history.confirming on a non-obscured input widget.Disclaimer: this PR was written with the help of Claude Code.