File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5151class CompletionItem :
5252 """A single completion result."""
5353
54+ _SANITIZE_RE = re .compile (r'\r\n|[\n\r\t\f\v]' )
55+
5456 # The underlying object this completion represents (e.g., str, int, Path).
5557 # This is used to support argparse choices validation.
5658 value : Any = field (kw_only = False )
@@ -76,14 +78,14 @@ class CompletionItem:
7678 display_plain : str = field (init = False )
7779 display_meta_plain : str = field (init = False )
7880
79- @staticmethod
80- def _sanitize_display_string (val : str ) -> str :
81+ @classmethod
82+ def _sanitize_display_string (cls , val : str ) -> str :
8183 """Sanitize a string for display in the completion menu.
8284
8385 This replaces whitespace characters that are rendered as
8486 control sequences (like ^J or ^I) with spaces.
8587 """
86- return re . sub (r'\r\n|[\n\r\t\f\v]' , ' ' , val )
88+ return cls . _SANITIZE_RE . sub (' ' , val )
8789
8890 def __post_init__ (self ) -> None :
8991 """Finalize the object after initialization."""
You can’t perform that action at this time.
0 commit comments