@@ -69,6 +69,7 @@ struct CachedLayout {
6969 bytes : usize ,
7070 measured : MeasuredText < Px > ,
7171 placeholder : MeasuredText < Px > ,
72+ sentinel : MeasuredText < Px > ,
7273 key : CacheKey ,
7374}
7475
@@ -571,7 +572,7 @@ where
571572 && cache. placeholder . can_render_to ( & context. gfx )
572573 && cache. key == key => { }
573574 _ => {
574- let ( bytes, measured, placeholder, ) = self . value . map_ref ( |storage| {
575+ let ( bytes, measured, placeholder, sentinel ) = self . value . map_ref ( |storage| {
575576 let mut text = storage. as_str ( ) ;
576577 let mut bytes = text. len ( ) ;
577578
@@ -608,12 +609,14 @@ where
608609
609610 let placeholder_color = context. theme ( ) . surface . on_color_variant ;
610611 let placeholder = self . placeholder . map ( |placeholder| context. gfx . measure_text ( Text :: new ( placeholder, placeholder_color) ) ) ;
611- ( bytes, context. gfx . measure_text ( text) , placeholder)
612+ let sentinel = context. gfx . measure_text ( "yjgTL" ) ;
613+ ( bytes, context. gfx . measure_text ( text) , placeholder, sentinel)
612614 } ) ;
613615 self . cache = Some ( CachedLayout {
614616 bytes,
615617 measured,
616618 placeholder,
619+ sentinel,
617620 key,
618621 } ) ;
619622 }
@@ -1072,14 +1075,7 @@ where
10721075 } ) ;
10731076 }
10741077
1075- // TODO: Approximating the descent is not great. We probably should
1076- // measure a letter with a descender and use that size as a minimum.
1077- let full_line_height = info. cache . measured . line_height
1078- - info
1079- . cache
1080- . measured
1081- . descent
1082- . min ( ( -info. cache . measured . line_height / 3 ) . ceil ( ) ) ;
1078+ let full_line_height = info. cache . sentinel . line_height - info. cache . sentinel . descent ;
10831079 if let Some ( selection) = info. selection {
10841080 let ( start, end) = if selection < info. cursor {
10851081 ( selection, info. cursor )
@@ -1191,7 +1187,7 @@ where
11911187
11921188 WidgetLayout {
11931189 size : available_space. fit_measured ( measured_size) ,
1194- baseline : Baseline :: from ( padding + info. cache . measured . line_height . into_unsigned ( ) ) ,
1190+ baseline : Baseline :: from ( padding + info. cache . sentinel . line_height . into_unsigned ( ) ) ,
11951191 }
11961192 }
11971193
0 commit comments