Skip to content

feat: input history#3939

Open
OliverGuy wants to merge 17 commits into
sxyazi:mainfrom
OliverGuy:feat/history
Open

feat: input history#3939
OliverGuy wants to merge 17 commits into
sxyazi:mainfrom
OliverGuy:feat/history

Conversation

@OliverGuy
Copy link
Copy Markdown

Which issue does this PR resolve?

Resolves #3723

Rationale of this PR

Adds command history to the input widget, similar to shell history navigation.

  • Bound in keymap.toml via history <n>, where n is a potentially negative integer offset.
  • Global state INPUT_HISTORY that stores input history.
  • New entries are added to the state when confirming on a non-obscured input widget.
  • Tracks independent undo/redo snaps per history "line."

Disclaimer: this PR was written with the help of Claude Code.

Copy link
Copy Markdown
Owner

@sxyazi sxyazi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch! A few change requests:

  • INPUT_HISTORY should be changed to a field named history on yazi_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.rs should likewise be a component action, not a widget action, i.e. it should live under yazi_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 20 entries to keep the design simple.

@OliverGuy
Copy link
Copy Markdown
Author

Hope this is what you had in mind :)

Comment thread yazi-config/src/popup/options.rs Outdated
pub position: Position,
pub realtime: bool,
pub completion: bool,
pub id: String,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please place id before the existing title, and change its type to SStr

Comment thread yazi-config/src/popup/options.rs Outdated
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(),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please place id before the existing title, and change its type to SStr

Comment thread yazi-config/src/popup/options.rs Outdated
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(),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Comment thread yazi-config/src/popup/options.rs Outdated
Self {
title: YAZI.input.rename_title.clone(),
position: Position::new(YAZI.input.rename_origin, YAZI.input.rename_offset),
id: "rename".to_owned(),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Comment thread yazi-config/src/popup/options.rs Outdated
title: YAZI.input.filter_title.clone(),
position: Position::new(YAZI.input.filter_origin, YAZI.input.filter_offset),
realtime: true,
id: "filter".to_owned(),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Comment thread yazi-widgets/src/input/history.rs Outdated

#[derive(Default)]
pub struct InputHistory {
entries: std::collections::VecDeque<String>,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
entries: std::collections::VecDeque<String>,
entries: VecDeque<String>,

Comment thread yazi-widgets/src/input/history.rs Outdated
#[derive(Default)]
pub struct InputHistory {
entries: std::collections::VecDeque<String>,
entry_snaps: std::collections::VecDeque<Option<InputSnaps>>,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
entry_snaps: std::collections::VecDeque<Option<InputSnaps>>,
entry_snaps: VecDeque<Option<InputSnaps>>,

Comment thread yazi-widgets/src/input/history.rs Outdated
impl InputHistory {
pub const fn new() -> Self {
Self {
entries: std::collections::VecDeque::new(),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
entries: std::collections::VecDeque::new(),
entries: VecDeque::new(),

Comment thread yazi-widgets/src/input/history.rs Outdated
pub const fn new() -> Self {
Self {
entries: std::collections::VecDeque::new(),
entry_snaps: std::collections::VecDeque::new(),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
entry_snaps: std::collections::VecDeque::new(),
entry_snaps: VecDeque::new(),

Comment thread yazi-widgets/src/input/history.rs Outdated
@@ -0,0 +1,93 @@
use std::mem;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this file to yazi_core::input

@OliverGuy
Copy link
Copy Markdown
Author

OliverGuy commented May 20, 2026

The changes should have been addressed, I'll let you mark them as resolved as you review 😃

@sxyazi sxyazi force-pushed the main branch 6 times, most recently from 00e4151 to 7a51626 Compare May 28, 2026 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text/entry boxes have history and completion

2 participants