File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
src/cortex-tui/src/widgets Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -85,12 +85,12 @@ impl<'a> MentionPopup<'a> {
8585 let item_count = self . state . visible_results ( ) . len ( ) as u16 ;
8686 let height = ( item_count + 2 ) . min ( MAX_HEIGHT + 2 ) ; // +2 for borders
8787
88- // Calculate width based on content
88+ // Calculate width based on content (use chars().count() for Unicode support)
8989 let content_width = self
9090 . state
9191 . results ( )
9292 . iter ( )
93- . map ( |p| p. to_string_lossy ( ) . len ( ) )
93+ . map ( |p| p. to_string_lossy ( ) . chars ( ) . count ( ) )
9494 . max ( )
9595 . unwrap_or ( 20 ) as u16 ;
9696
@@ -195,8 +195,11 @@ impl Widget for MentionPopup<'_> {
195195
196196 let ( width, height) = self . calculate_dimensions ( area) ;
197197
198- // Position the popup
199- let popup_area = if self . above {
198+ // Position the popup - check if it fits above, otherwise render below
199+ let fits_above = area. y >= height;
200+ let render_above = self . above && fits_above;
201+
202+ let popup_area = if render_above {
200203 Rect :: new ( area. x , area. y . saturating_sub ( height) , width, height)
201204 } else {
202205 Rect :: new (
You can’t perform that action at this time.
0 commit comments