@@ -289,6 +289,7 @@ struct State<Highlighter: text::Highlighter> {
289289 is_focused : bool ,
290290 last_click : Option < mouse:: Click > ,
291291 drag_click : Option < mouse:: click:: Kind > ,
292+ partial_scroll : f32 ,
292293 highlighter : RefCell < Highlighter > ,
293294 highlighter_settings : Highlighter :: Settings ,
294295 highlighter_format_address : usize ,
@@ -310,6 +311,7 @@ where
310311 is_focused : false ,
311312 last_click : None ,
312313 drag_click : None ,
314+ partial_scroll : 0.0 ,
313315 highlighter : RefCell :: new ( Highlighter :: new (
314316 & self . highlighter_settings ,
315317 ) ) ,
@@ -404,6 +406,14 @@ where
404406
405407 shell. publish ( on_edit ( action) ) ;
406408 }
409+ Update :: Scroll ( lines) => {
410+ let lines = lines + state. partial_scroll ;
411+ state. partial_scroll = lines. fract ( ) ;
412+
413+ shell. publish ( on_edit ( Action :: Scroll {
414+ lines : lines as i32 ,
415+ } ) ) ;
416+ }
407417 Update :: Unfocus => {
408418 state. is_focused = false ;
409419 state. drag_click = None ;
@@ -577,6 +587,7 @@ where
577587
578588enum Update {
579589 Click ( mouse:: Click ) ,
590+ Scroll ( f32 ) ,
580591 Unfocus ,
581592 Release ,
582593 Action ( Action ) ,
@@ -630,21 +641,16 @@ impl Update {
630641 mouse:: Event :: WheelScrolled { delta }
631642 if cursor. is_over ( bounds) =>
632643 {
633- action ( Action :: Scroll {
634- lines : match delta {
635- mouse:: ScrollDelta :: Lines { y, .. } => {
636- if y. abs ( ) > 0.0 {
637- ( y. signum ( ) * -( y. abs ( ) * 4.0 ) . max ( 1.0 ) )
638- as i32
639- } else {
640- 0
641- }
642- }
643- mouse:: ScrollDelta :: Pixels { y, .. } => {
644- ( -y / 4.0 ) as i32
644+ Some ( Update :: Scroll ( match delta {
645+ mouse:: ScrollDelta :: Lines { y, .. } => {
646+ if y. abs ( ) > 0.0 {
647+ y. signum ( ) * -( y. abs ( ) * 4.0 ) . max ( 1.0 )
648+ } else {
649+ 0.0
645650 }
646- } ,
647- } )
651+ }
652+ mouse:: ScrollDelta :: Pixels { y, .. } => -y / 4.0 ,
653+ } ) )
648654 }
649655 _ => None ,
650656 } ,
0 commit comments