##// END OF EJS Templates
Limit number of completions returned
Thomas Kluyver -
Show More
@@ -161,6 +161,9 b" if sys.platform == 'win32':"
161 161 else:
162 162 PROTECTABLES = ' ()[]{}?=\\|;:\'#*"^&'
163 163
164 # Protect against returning an enormous number of completions which the frontend
165 # may have trouble processing.
166 MATCHES_LIMIT = 500
164 167
165 168 _deprecation_readline_sentinel = object()
166 169
@@ -1944,7 +1947,8 b' class IPCompleter(Completer):'
1944 1947 for meth in (self.unicode_name_matches, back_latex_name_matches, back_unicode_name_matches):
1945 1948 name_text, name_matches = meth(base_text)
1946 1949 if name_text:
1947 return name_text, name_matches, [meth.__qualname__]*len(name_matches), ()
1950 return name_text, name_matches[:MATCHES_LIMIT], \
1951 [meth.__qualname__]*min(len(name_matches), MATCHES_LIMIT), ()
1948 1952
1949 1953
1950 1954 # If no line buffer is given, assume the input text is all there was
@@ -1956,11 +1960,10 b' class IPCompleter(Completer):'
1956 1960
1957 1961 # Do magic arg matches
1958 1962 for matcher in self.magic_arg_matchers:
1959 matches = [(m, matcher.__qualname__) for m in matcher(line_buffer)]
1963 matches = list(matcher(line_buffer))[:MATCHES_LIMIT]
1960 1964 if matches:
1961 matches2 = [m[0] for m in matches]
1962 origins = [m[1] for m in matches]
1963 return text, matches2, origins, ()
1965 origins = [matcher.__qualname__] * len(matches)
1966 return text, matches, origins, ()
1964 1967
1965 1968 # Start with a clean slate of completions
1966 1969 matches = []
@@ -2007,7 +2010,8 b' class IPCompleter(Completer):'
2007 2010 seen.add(t)
2008 2011
2009 2012 _filtered_matches = sorted(
2010 set(filtered_matches), key=lambda x: completions_sorting_key(x[0]))
2013 set(filtered_matches), key=lambda x: completions_sorting_key(x[0]))\
2014 [:MATCHES_LIMIT]
2011 2015
2012 2016 _matches = [m[0] for m in _filtered_matches]
2013 2017 origins = [m[1] for m in _filtered_matches]
General Comments 0
You need to be logged in to leave comments. Login now