##// END OF EJS Templates
Merge pull request #11474 from emjobson/longFileCompleteFix...
Matthias Bussonnier -
r24854:eb5918d0 merge
parent child Browse files
Show More
@@ -19,12 +19,16 b' from prompt_toolkit.lexers import PygmentsLexer'
19 19 from prompt_toolkit.patch_stdout import patch_stdout
20 20
21 21 import pygments.lexers as pygments_lexers
22 import os
22 23
23 24 _completion_sentinel = object()
24 25
25 26 def _elide(string, *, min_elide=30):
26 27 """
27 If a string is long enough, and has at least 2 dots,
28 If a string is long enough, and has at least 3 dots,
29 replace the middle part with ellipses.
30
31 If a string naming a file is long enough, and has at least 3 slashes,
28 32 replace the middle part with ellipses.
29 33
30 34 If three consecutive dots, or two consecutive dots are encountered these are
@@ -36,12 +40,16 b' def _elide(string, *, min_elide=30):'
36 40 if len(string) < min_elide:
37 41 return string
38 42
39 parts = string.split('.')
43 object_parts = string.split('.')
44 file_parts = string.split(os.sep)
40 45
41 if len(parts) <= 3:
42 return string
46 if len(object_parts) > 3:
47 return '{}.{}\N{HORIZONTAL ELLIPSIS}{}.{}'.format(object_parts[0], object_parts[1][0], object_parts[-2][-1], object_parts[-1])
48
49 elif len(file_parts) > 3:
50 return ('{}' + os.sep + '{}\N{HORIZONTAL ELLIPSIS}{}' + os.sep + '{}').format(file_parts[0], file_parts[1][0], file_parts[-2][-1], file_parts[-1])
43 51
44 return '{}.{}\N{HORIZONTAL ELLIPSIS}{}.{}'.format(parts[0], parts[1][0], parts[-2][-1], parts[-1])
52 return string
45 53
46 54
47 55 def _adjust_completion_text_based_on_context(text, body, offset):
General Comments 0
You need to be logged in to leave comments. Login now