Skip to content

history search in prompts#15266

Open
Axlefublr wants to merge 1 commit intohelix-editor:masterfrom
Axlefublr:Axlefublr/uparrow
Open

history search in prompts#15266
Axlefublr wants to merge 1 commit intohelix-editor:masterfrom
Axlefublr:Axlefublr/uparrow

Conversation

@Axlefublr
Copy link
Contributor

@Axlefublr Axlefublr commented Feb 6, 2026

Previously, and in prompts didn't care at all about what you have typed in — they would always cycle through the entire history.
Now the behavior is different depending on if the prompt input is empty, or filled with something.

If the prompt input is empty, ↓↑ work like normal.
If the prompt input is not empty, and it reached this state not by ↓↑, your current prompt input is taken as a substring pattern that you search for in your history.

This works for all prompts, but I'm going to use command mode as the example.
Assume you have this in your command mode history:

echo tomato
echo potato
echo potatotron
echo lemon

With your prompt input empty, ↑ will result in echo lemon.
But if instead you type in potato and tap ↑, you will arrive at echo potatotron. If from this state you press again, you reach echo potato.
Pressing ↑ again doesn't change anything because echo potato is the oldest command that substring matches the current pattern (potato)

If after arriving at echo potatotron for the first time you edit your input in any way (even ←→ counts as an “edit” here), then that now becomes your current pattern.
Type in potato, tap ↑, end up at echo potatotron. Press ← then ↑ — nothing happens, because you are at the only result of the new pattern (echo potatotron).

If instead of pressing ← you edited echo potatotron to echo potatotronistic and pressed ↑ — nothing would happen also, because there are no matches for that in the history.

If you've used fish shell, you can refer to the ↑ behavior there: that's more or less the behavior that I'm replicating.

@Axlefublr
Copy link
Contributor Author

The failing test is with regards to the history completion behavior as expected. But since with this pr we expect a different behavior to begin with, I'm not gonna touch it for now.

#[tokio::test(flavor = "multi_thread")]
async fn history_completion() -> anyhow::Result<()> {
    test_key_sequence(
        &mut AppBuilder::new().build()?,
        Some(":asdf<ret>:theme d<C-n><tab>"),
        Some(&|app| {
            assert!(!app.editor.is_err());
        }),
        false,
    )
    .await?;

    Ok(())
}

@Axlefublr
Copy link
Contributor Author

For people interested in this feature, you might also like #15271

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.

1 participant