##// END OF EJS Templates
Lazy load unicode names
zzzz-qq -
Show More
@@ -168,12 +168,6 b' MATCHES_LIMIT = 500'
168
168
169 _deprecation_readline_sentinel = object()
169 _deprecation_readline_sentinel = object()
170
170
171 names = []
172 for c in range(0,0x10FFFF + 1):
173 try:
174 names.append(unicodedata.name(chr(c)))
175 except ValueError:
176 pass
177
171
178 class ProvisionalCompleterWarning(FutureWarning):
172 class ProvisionalCompleterWarning(FutureWarning):
179 """
173 """
@@ -998,6 +992,8 b' def _make_signature(completion)-> str:'
998 class IPCompleter(Completer):
992 class IPCompleter(Completer):
999 """Extension of the completer class with IPython-specific features"""
993 """Extension of the completer class with IPython-specific features"""
1000
994
995 _names = None
996
1001 @observe('greedy')
997 @observe('greedy')
1002 def _greedy_changed(self, change):
998 def _greedy_changed(self, change):
1003 """update the splitter and readline delims when greedy is changed"""
999 """update the splitter and readline delims when greedy is changed"""
@@ -2073,14 +2069,21 b' class IPCompleter(Completer):'
2073 return text, _matches, origins, completions
2069 return text, _matches, origins, completions
2074
2070
2075 def fwd_unicode_match(self, text:str) -> Tuple[str, list]:
2071 def fwd_unicode_match(self, text:str) -> Tuple[str, list]:
2076 # initial code based on latex_matches() method
2072 if self._names is None:
2073 self._names = []
2074 for c in range(0,0x10FFFF + 1):
2075 try:
2076 self._names.append(unicodedata.name(chr(c)))
2077 except ValueError:
2078 pass
2079
2077 slashpos = text.rfind('\\')
2080 slashpos = text.rfind('\\')
2078 # if text starts with slash
2081 # if text starts with slash
2079 if slashpos > -1:
2082 if slashpos > -1:
2080 s = text[slashpos+1:]
2083 s = text[slashpos+1:]
2081 candidates = [x for x in names if x.startswith(s)]
2084 candidates = [x for x in self._names if x.startswith(s)]
2082 if candidates:
2085 if candidates:
2083 return s, [x for x in names if x.startswith(s)]
2086 return s, candidates
2084 else:
2087 else:
2085 return '', ()
2088 return '', ()
2086
2089
General Comments 0
You need to be logged in to leave comments. Login now