File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -368,6 +368,16 @@ def _get_item_lookup_completions(
368368 """
369369 Complete dictionary keys.
370370 """
371+
372+ def abbr_meta (text : str ) -> str :
373+ " Abbreviate meta text, make sure it fits on one line. "
374+ # Take first line, if multiple lines.
375+ if len (text ) > 20 :
376+ text = text [:20 ] + "..."
377+ if "\n " in text :
378+ text = text .split ("\n " , 1 )[0 ] + "..."
379+ return text
380+
371381 match = self .item_lookup_pattern .search (document .text_before_cursor )
372382 if match is not None :
373383 object_var , key = match .groups ()
@@ -395,7 +405,7 @@ def _get_item_lookup_completions(
395405 k_repr + "]" ,
396406 - len (key ),
397407 display = f"[{ k_repr } ]" ,
398- display_meta = self ._do_repr (result [k ]),
408+ display_meta = abbr_meta ( self ._do_repr (result [k ]) ),
399409 )
400410 except ReprFailedError :
401411 pass
@@ -411,7 +421,7 @@ def _get_item_lookup_completions(
411421 k_repr + "]" ,
412422 - len (key ),
413423 display = f"[{ k_repr } ]" ,
414- display_meta = self ._do_repr (result [k ]),
424+ display_meta = abbr_meta ( self ._do_repr (result [k ]) ),
415425 )
416426 except ReprFailedError :
417427 pass
You can’t perform that action at this time.
0 commit comments