From 6c1027af8d54ad21e282337b53097eb196d62c00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Mon, 17 Jun 2024 03:37:00 +0200 Subject: [PATCH] Fix `text_editor` always capturing scroll events --- graphics/src/text/editor.rs | 12 ++++-------- widget/src/text_editor.rs | 6 ++++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/graphics/src/text/editor.rs b/graphics/src/text/editor.rs index 4b8f0f2ade..c488a51c61 100644 --- a/graphics/src/text/editor.rs +++ b/graphics/src/text/editor.rs @@ -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 }, + ); } } diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs index 41b058afc0..fc2ade4326 100644 --- a/widget/src/text_editor.rs +++ b/widget/src/text_editor.rs @@ -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();