Skip to content

Commit

Permalink
Fix text_editor always capturing scroll events
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Jun 17, 2024
1 parent e9141e7 commit 6c1027a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 4 additions & 8 deletions graphics/src/text/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,14 +456,10 @@ impl editor::Editor for Editor {
}
}
Action::Scroll { lines } => {
let (_, height) = editor.buffer().size();

if height < i32::MAX as f32 {
editor.action(
font_system.raw(),
cosmic_text::Action::Scroll { lines },
);
}
editor.action(
font_system.raw(),
cosmic_text::Action::Scroll { lines },
);
}
}

Expand Down
6 changes: 6 additions & 0 deletions widget/src/text_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,12 @@ where
shell.publish(on_edit(action));
}
Update::Scroll(lines) => {
let bounds = self.content.0.borrow().editor.bounds();

if bounds.height >= i32::MAX as f32 {
return event::Status::Ignored;
}

let lines = lines + state.partial_scroll;
state.partial_scroll = lines.fract();

Expand Down

0 comments on commit 6c1027a

Please sign in to comment.