File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
src/prompt_toolkit/layout Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -709,7 +709,19 @@ def preferred_width(self, max_available_width: int) -> Optional[int]:
709
709
app = get_app ()
710
710
if app .current_buffer .complete_state :
711
711
state = app .current_buffer .complete_state
712
- return 2 + max (get_cwidth (c .display_meta_text ) for c in state .completions )
712
+
713
+ if len (state .completions ) >= 30 :
714
+ # When there are many completions, calling `get_cwidth` for
715
+ # every `display_meta_text` is too expensive. In this case,
716
+ # just return the max available width. There will be enough
717
+ # columns anyway so that the whole screen is filled with
718
+ # completions and `create_content` will then take up as much
719
+ # space as needed.
720
+ return max_available_width
721
+
722
+ return 2 + max (
723
+ get_cwidth (c .display_meta_text ) for c in state .completions [:100 ]
724
+ )
713
725
else :
714
726
return 0
715
727
You can’t perform that action at this time.
0 commit comments