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 and backspace corrupt commandline #239

Closed
sophiajt opened this issue Jun 9, 2019 · 4 comments
Closed

History and backspace corrupt commandline #239

sophiajt opened this issue Jun 9, 2019 · 4 comments
Labels

Comments

@sophiajt
Copy link

sophiajt commented Jun 9, 2019

With the latest rustyline, if you do the following steps, you get a corrupted input line. You can repro this using the same app

cargo run --example example

Next, type something into one line:

1> this is a test file
Line: this is a test file

Next, press up, to get to the previous line, move the arrow to get to the word test and backspace to delete it.

This is what it looks like when I do this:

Screenshot from 2019-06-09 17-24-56

Notice the line is now corrupted and is showing both the editing line and something from the previous history of the line.

@gwenn gwenn added the bug label Jun 9, 2019
@gwenn
Copy link
Collaborator

gwenn commented Jun 9, 2019

The highlighted/bold text is the suggestion/hint based on history.
The current implementation does not check if the cursor is at the end of the line / if the whole line matches a previous history entry.
https://github.com/kkawakam/rustyline/blob/master/src/hint.rs#L37

    fn hint(&self, line: &str, pos: usize, ctx: &Context<'_>) -> Option<String> {
...
        if let Some(history_index) =
            ctx.history
                .starts_with(&line[..pos], start, Direction::Reverse)
...

@gwenn
Copy link
Collaborator

gwenn commented Jun 9, 2019

liner does not display any suggestion while editing an history entry:
https://github.com/redox-os/liner/blob/master/src/editor.rs#L863

        // If we are editing a previous history item no autosuggestion.
        if self.hist_buf_valid {
            return None;
        }

@gwenn
Copy link
Collaborator

gwenn commented Jun 9, 2019

See #240

@sophiajt
Copy link
Author

sophiajt commented Jun 9, 2019

That fix works for me, thanks!

@sophiajt sophiajt closed this as completed Jun 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants