Skip to content

Commit

Permalink
Fix cursor jumping when moving in whitespace at EOL
Browse files Browse the repository at this point in the history
This fixes the issue with the cursor jumping, but does not fix
the underlying problem, which is related to us not providing a
good API for including the whitespace in text width calculations.

see #1430
  • Loading branch information
cmyr committed Nov 26, 2020
1 parent e677854 commit 92e4dfb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion druid/src/widget/textbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,10 @@ impl<T: TextStorage + EditableText> TextBox<T> {
/// Calculate a stateful scroll offset
fn update_hscroll(&mut self, self_width: f64, env: &Env) {
let cursor_x = self.editor.cursor_line().p0.x;
let overall_text_width = self.editor.layout().size().width;
// if the text ends in trailing whitespace, that space is not included
// in its reported width, but we need to include it for these calculations.
// see https://github.com/linebender/druid/issues/1430
let overall_text_width = self.editor.layout().size().width.max(cursor_x);
let text_insets = env.get(theme::TEXTBOX_INSETS);

//// when advancing the cursor, we want some additional padding
Expand Down

0 comments on commit 92e4dfb

Please sign in to comment.