##// END OF EJS Templates
Minor improvements to completion...
Matthias Bussonnier -
Show More
@@ -11,7 +11,7 b' import unicodedata'
11 from wcwidth import wcwidth
11 from wcwidth import wcwidth
12
12
13 from IPython.core.completer import (
13 from IPython.core.completer import (
14 IPCompleter, provisionalcompleter, rectify_completions, cursor_to_position,
14 provisionalcompleter, cursor_to_position,
15 _deduplicate_completions)
15 _deduplicate_completions)
16 from prompt_toolkit.completion import Completer, Completion
16 from prompt_toolkit.completion import Completer, Completion
17 from prompt_toolkit.layout.lexers import Lexer
17 from prompt_toolkit.layout.lexers import Lexer
@@ -21,6 +21,23 b' import pygments.lexers as pygments_lexers'
21
21
22 _completion_sentinel = object()
22 _completion_sentinel = object()
23
23
24 def _elide(string, *, min_elide=30):
25 """
26 If a string is long enough, and has at least 2 dots,
27 replace the middle part with ellipses.
28
29 For example:
30 """
31 if len(string) < min_elide:
32 return string
33
34 parts = string.split('.')
35
36 if len(parts) <= 3:
37 return string
38
39 return '{}.{}\N{HORIZONTAL ELLIPSIS}{}.{}'.format(parts[0], parts[1][0], parts[-2][-1], parts[-1])
40
24
41
25
42
26
43
@@ -90,7 +107,12 b' class IPythonPTCompleter(Completer):'
90 # meta_text = ''
107 # meta_text = ''
91 # yield Completion(m, start_position=start_pos,
108 # yield Completion(m, start_position=start_pos,
92 # display_meta=meta_text)
109 # display_meta=meta_text)
93 yield Completion(c.text, start_position=c.start - offset, display_meta=c.type)
110 display_text = c.text
111
112 if c.type == 'function':
113 display_text = display_text + '()'
114
115 yield Completion(c.text, start_position=c.start - offset, display=_elide(display_text), display_meta=c.type)
94
116
95 class IPythonPTLexer(Lexer):
117 class IPythonPTLexer(Lexer):
96 """
118 """
General Comments 0
You need to be logged in to leave comments. Login now