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

text_editor panics when up/down arrows are pressed at end of text #78

Open
aadishv opened this issue Feb 13, 2025 · 0 comments
Open

text_editor panics when up/down arrows are pressed at end of text #78

aadishv opened this issue Feb 13, 2025 · 0 comments

Comments

@aadishv
Copy link

aadishv commented Feb 13, 2025

When running the following code:

use rui::*;

fn main() {
    state(|| "Hello".to_owned(), |handle, _| text_editor(handle)).run()
}

on my mac, if you take the cursor to the end of the text and press up/down arrows, app panics. This is because of this:

// src/views/text_editor.rs:64 
let p = self.glyph_rects[self.cursor].center();

which fails to account for when self.cursor == self.glyph_rects.len().

also the find_line() function is acting a little weird; in this example, it thinks that the line is 1 and not 0 (thus, when I press up and if the above error is fixed, it thinks the line is 1 and thus still tries to jump a line up)

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