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

History doesn't seem to work for Readline #40

Open
Tommypop2 opened this issue Dec 10, 2024 · 0 comments
Open

History doesn't seem to work for Readline #40

Tommypop2 opened this issue Dec 10, 2024 · 0 comments

Comments

@Tommypop2
Copy link

Description

Using the arrows to navigate history doesn't work.

Reproduction

use promkit::{preset::readline::Readline, suggest::Suggest};

fn main() -> anyhow::Result<()> {
    let mut p = Readline::default()
        .enable_history()
        .enable_suggest(Suggest::from_iter([
            "apple",
            "applet",
            "application",
            "banana",
        ]))
        .prompt()?;
    loop {
        match p.run() {
            Ok(cmd) => {
                println!("result: {:?}", cmd);
            }
            Err(_) => {
                println!("Bye!");
                break;
            }
        }
    }
    Ok(())
}

Additional Info

When I try to log the history, it seems like the contents section is empty and doesn't get added to.
I tried adding the text entry manually to the history:

use promkit::{preset::readline::Readline, suggest::Suggest};

fn main() -> anyhow::Result<()> {
    let mut p = Readline::default()
        .enable_history()
        .enable_suggest(Suggest::from_iter([
            "apple",
            "applet",
            "application",
            "banana",
        ]))
        .prompt()?;
    loop {
        match p.run() {
            Ok(cmd) => {
                println!("result: {:?}", cmd);
                p.renderer
                    .text_editor_snapshot
                    .after_mut()
                    .history
                    .as_mut()
                    .unwrap()
                    .insert(cmd);
            }
            Err(_) => {
                println!("Bye!");
                break;
            }
        }
    }
    Ok(())
}

This worked for a single entry (I could press the up arrow once to get the previous command) but I couldn't go any further

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

No branches or pull requests

1 participant