@@ -882,49 +882,51 @@ where
882882
883883 let translation = text_bounds. position ( ) - Point :: ORIGIN ;
884884
885- if let Some ( focus) = state. focus . as_ref ( ) {
886- match internal. editor . cursor ( ) {
887- Cursor :: Caret ( position) if focus. is_cursor_visible ( ) => {
888- let cursor =
889- Rectangle :: new (
890- position + translation,
891- Size :: new (
892- 1.0 ,
893- self . line_height
894- . to_absolute ( self . text_size . unwrap_or_else (
895- || renderer. default_size ( ) ,
896- ) )
897- . into ( ) ,
898- ) ,
899- ) ;
885+ match internal. editor . cursor ( ) {
886+ Cursor :: Caret ( position)
887+ if state
888+ . focus
889+ . as_ref ( )
890+ . is_some_and ( Focus :: is_cursor_visible) =>
891+ {
892+ let cursor = Rectangle :: new (
893+ position + translation,
894+ Size :: new (
895+ 1.0 ,
896+ self . line_height
897+ . to_absolute (
898+ self . text_size
899+ . unwrap_or_else ( || renderer. default_size ( ) ) ,
900+ )
901+ . into ( ) ,
902+ ) ,
903+ ) ;
900904
901- if let Some ( clipped_cursor) =
902- text_bounds. intersection ( & cursor)
903- {
904- renderer. fill_quad (
905- renderer:: Quad {
906- bounds : clipped_cursor,
907- ..renderer:: Quad :: default ( )
908- } ,
909- style. value ,
910- ) ;
911- }
905+ if let Some ( clipped_cursor) = text_bounds. intersection ( & cursor)
906+ {
907+ renderer. fill_quad (
908+ renderer:: Quad {
909+ bounds : clipped_cursor,
910+ ..renderer:: Quad :: default ( )
911+ } ,
912+ style. value ,
913+ ) ;
912914 }
913- Cursor :: Selection ( ranges ) => {
914- for range in ranges . into_iter ( ) . filter_map ( |range| {
915- text_bounds . intersection ( & ( range + translation ) )
916- } ) {
917- renderer . fill_quad (
918- renderer:: Quad {
919- bounds : range ,
920- ..renderer :: Quad :: default ( )
921- } ,
922- style . selection ,
923- ) ;
924- }
915+ }
916+ Cursor :: Selection ( ranges ) => {
917+ for range in ranges . into_iter ( ) . filter_map ( | range| {
918+ text_bounds . intersection ( & ( range + translation ) )
919+ } ) {
920+ renderer. fill_quad (
921+ renderer :: Quad {
922+ bounds : range ,
923+ ..renderer :: Quad :: default ( )
924+ } ,
925+ style . selection ,
926+ ) ;
925927 }
926- Cursor :: Caret ( _) => { }
927928 }
929+ Cursor :: Caret ( _) => { }
928930 }
929931 }
930932
0 commit comments