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

Cursor slowdown when pressing left/right arrows and there is a lot of text in the prompt #795

Open
rendarz opened this issue May 29, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@rendarz
Copy link

rendarz commented May 29, 2024

I have just an hello world project with few lines of code:

use reedline::{DefaultPrompt, DefaultPromptSegment, Reedline, Signal};


fn main() {
	let mut line_editor = Reedline::create();
	let prompt = DefaultPrompt::new(DefaultPromptSegment::Basic("ok".to_string()), DefaultPromptSegment::Empty);

	loop {
            let sig = line_editor.read_line(&prompt);
            match sig {
                Ok(Signal::Success(buffer)) => {
                    println!("We processed: {}", buffer);
                 },
                Ok(Signal::CtrlD) | Ok(Signal::CtrlC) => {
                    println!("\nAborted!");
                    break;
                 },
                 _ => { },
             }
         }
    }	
}

When I run this very simple project, with a very short text prompt, I have noticed that when I press the left or right arrows, there is some kind of delay - internally - that makes the cursor not responsive!
Indeed, if I leave the arrow keys, I noticed that the cursor is still moving, and doesn't stop immediately.
Again, it's like there is a little and subtle delay, but very annoying.
I've attached a video to show this, as you can see from the video, when I leave my finger from the arrow key, the cursor is still moving...
NOTE: This DOES NOT happen with other command-lines prompt crates.

IMG_2640.mp4
@rendarz rendarz added the bug Something isn't working label May 29, 2024
@fdncred
Copy link
Collaborator

fdncred commented May 29, 2024

Maybe I'm missing the point here, but it looks like the repeat setting for your keyboard is very fast. If you hold in a key, it typically repeats, like it did when you held in the l key. That repeat speed is usually controllable. If you hold it in and reedline hears 100 left repeats before you release the button, I'm not sure how to tell it, "I'm just kidding. I don't want 100, I only want 5.", or however many.

@rendarz
Copy link
Author

rendarz commented May 30, 2024

Maybe I'm missing the point here, but it looks like the repeat setting for your keyboard is very fast. If you hold in a key, it typically repeats, like it did when you held in the l key. That repeat speed is usually controllable. If you hold it in and reedline hears 100 left repeats before you release the button, I'm not sure how to tell it, "I'm just kidding. I don't want 100, I only want 5.", or however many.

Hi, yes my keyboard repeat is fast, that's a fact, but it doesn't mean the crate hasn't a bug... when I release my arrow key the cursor should stop immediately, like it happens with EVERTHING else, console, vim, emacs, terminal, even LibreOffice, or gedit, or even the competing rustyline crate! Trust me, there is something wrong. Why are left and right arrows so unnaturally lagged? I think it's worth investigating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants