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(
368
368
"""
369
369
Complete dictionary keys.
370
370
"""
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
+
371
381
match = self .item_lookup_pattern .search (document .text_before_cursor )
372
382
if match is not None :
373
383
object_var , key = match .groups ()
@@ -395,7 +405,7 @@ def _get_item_lookup_completions(
395
405
k_repr + "]" ,
396
406
- len (key ),
397
407
display = f"[{ k_repr } ]" ,
398
- display_meta = self ._do_repr (result [k ]),
408
+ display_meta = abbr_meta ( self ._do_repr (result [k ]) ),
399
409
)
400
410
except ReprFailedError :
401
411
pass
@@ -411,7 +421,7 @@ def _get_item_lookup_completions(
411
421
k_repr + "]" ,
412
422
- len (key ),
413
423
display = f"[{ k_repr } ]" ,
414
- display_meta = self ._do_repr (result [k ]),
424
+ display_meta = abbr_meta ( self ._do_repr (result [k ]) ),
415
425
)
416
426
except ReprFailedError :
417
427
pass
You can’t perform that action at this time.
0 commit comments