##// END OF EJS Templates
Updated path completion for long path names to display the completed portion rather than the prefix. Will now elide for long file names as well as long object names....
Elliott Morgan Jobson -
Show More
@@ -24,7 +24,10 b' _completion_sentinel = object()'
24
24
25 def _elide(string, *, min_elide=30):
25 def _elide(string, *, min_elide=30):
26 """
26 """
27 If a string is long enough, and has at least 2 dots,
27 If a string is long enough, and has at least 3 dots,
28 replace the middle part with ellipses.
29
30 If a string naming a file is long enough, and has at least 3 slashes,
28 replace the middle part with ellipses.
31 replace the middle part with ellipses.
29
32
30 If three consecutive dots, or two consecutive dots are encountered these are
33 If three consecutive dots, or two consecutive dots are encountered these are
@@ -36,12 +39,16 b' def _elide(string, *, min_elide=30):'
36 if len(string) < min_elide:
39 if len(string) < min_elide:
37 return string
40 return string
38
41
39 parts = string.split('.')
42 object_parts = string.split('.')
43 file_parts = string.split('/')
40
44
41 if len(parts) <= 3:
45 if len(object_parts) > 3:
42 return string
46 return '{}.{}\N{HORIZONTAL ELLIPSIS}{}.{}'.format(parts[0], parts[1][0], parts[-2][-1], parts[-1])
47
48 elif len(file_parts) > 3:
49 return '{}/{}\N{HORIZONTAL ELLIPSIS}{}/{}'.format(parts[0], parts[1][0], parts[-2][-1], parts[-1])
43
50
44 return '{}.{}\N{HORIZONTAL ELLIPSIS}{}.{}'.format(parts[0], parts[1][0], parts[-2][-1], parts[-1])
51 return string
45
52
46
53
47 def _adjust_completion_text_based_on_context(text, body, offset):
54 def _adjust_completion_text_based_on_context(text, body, offset):
General Comments 0
You need to be logged in to leave comments. Login now