@@ -278,6 +278,7 @@ struct State<Highlighter: text::Highlighter> {
278278 is_focused : bool ,
279279 last_click : Option < mouse:: Click > ,
280280 drag_click : Option < mouse:: click:: Kind > ,
281+ partial_scroll : f32 ,
281282 highlighter : RefCell < Highlighter > ,
282283 highlighter_settings : Highlighter :: Settings ,
283284 highlighter_format_address : usize ,
@@ -299,6 +300,7 @@ where
299300 is_focused : false ,
300301 last_click : None ,
301302 drag_click : None ,
303+ partial_scroll : 0.0 ,
302304 highlighter : RefCell :: new ( Highlighter :: new (
303305 & self . highlighter_settings ,
304306 ) ) ,
@@ -394,6 +396,11 @@ where
394396
395397 shell. publish ( on_edit ( action) ) ;
396398 }
399+ Update :: Scroll ( mut lines) => {
400+ lines += state. partial_scroll ;
401+ state. partial_scroll = lines. fract ( ) ;
402+ shell. publish ( on_edit ( Action :: Scroll { lines : lines as i32 } ) )
403+ }
397404 Update :: Unfocus => {
398405 state. is_focused = false ;
399406 state. drag_click = None ;
@@ -565,6 +572,7 @@ where
565572
566573enum Update {
567574 Click ( mouse:: Click ) ,
575+ Scroll ( f32 ) ,
568576 Unfocus ,
569577 Release ,
570578 Action ( Action ) ,
@@ -617,21 +625,16 @@ impl Update {
617625 mouse:: Event :: WheelScrolled { delta }
618626 if cursor. is_over ( bounds) =>
619627 {
620- action ( Action :: Scroll {
621- lines : match delta {
622- mouse:: ScrollDelta :: Lines { y, .. } => {
623- if y. abs ( ) > 0.0 {
624- ( y. signum ( ) * -( y. abs ( ) * 4.0 ) . max ( 1.0 ) )
625- as i32
626- } else {
627- 0
628- }
629- }
630- mouse:: ScrollDelta :: Pixels { y, .. } => {
631- ( -y / 4.0 ) as i32
628+ Some ( Update :: Scroll ( match delta {
629+ mouse:: ScrollDelta :: Lines { y, .. } => {
630+ if y. abs ( ) > 0.0 {
631+ y. signum ( ) * -( y. abs ( ) * 4.0 ) . max ( 1.0 )
632+ } else {
633+ 0.0
632634 }
633- } ,
634- } )
635+ }
636+ mouse:: ScrollDelta :: Pixels { y, .. } => -y / 4.0 ,
637+ } ) )
635638 }
636639 _ => None ,
637640 } ,
0 commit comments