##// END OF EJS Templates
Merge pull request #10743 from takluyver/limit-no-completions...
Min RK -
r23848:03bb4e4c merge
parent child Browse files
Show More
@@ -5,6 +5,7 b' _build'
5 docs/man/*.gz
5 docs/man/*.gz
6 docs/source/api/generated
6 docs/source/api/generated
7 docs/source/config/options
7 docs/source/config/options
8 docs/source/config/shortcuts/*.csv
8 docs/source/interactive/magics-generated.txt
9 docs/source/interactive/magics-generated.txt
9 docs/source/config/shortcuts/*.csv
10 docs/source/config/shortcuts/*.csv
10 docs/gh-pages
11 docs/gh-pages
@@ -161,6 +161,9 b" if sys.platform == 'win32':"
161 else:
161 else:
162 PROTECTABLES = ' ()[]{}?=\\|;:\'#*"^&'
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 _deprecation_readline_sentinel = object()
168 _deprecation_readline_sentinel = object()
166
169
@@ -1943,7 +1946,8 b' class IPCompleter(Completer):'
1943 for meth in (self.unicode_name_matches, back_latex_name_matches, back_unicode_name_matches):
1946 for meth in (self.unicode_name_matches, back_latex_name_matches, back_unicode_name_matches):
1944 name_text, name_matches = meth(base_text)
1947 name_text, name_matches = meth(base_text)
1945 if name_text:
1948 if name_text:
1946 return name_text, name_matches, [meth.__qualname__]*len(name_matches), ()
1949 return name_text, name_matches[:MATCHES_LIMIT], \
1950 [meth.__qualname__]*min(len(name_matches), MATCHES_LIMIT), ()
1947
1951
1948
1952
1949 # If no line buffer is given, assume the input text is all there was
1953 # If no line buffer is given, assume the input text is all there was
@@ -1955,11 +1959,10 b' class IPCompleter(Completer):'
1955
1959
1956 # Do magic arg matches
1960 # Do magic arg matches
1957 for matcher in self.magic_arg_matchers:
1961 for matcher in self.magic_arg_matchers:
1958 matches = [(m, matcher.__qualname__) for m in matcher(line_buffer)]
1962 matches = list(matcher(line_buffer))[:MATCHES_LIMIT]
1959 if matches:
1963 if matches:
1960 matches2 = [m[0] for m in matches]
1964 origins = [matcher.__qualname__] * len(matches)
1961 origins = [m[1] for m in matches]
1965 return text, matches, origins, ()
1962 return text, matches2, origins, ()
1963
1966
1964 # Start with a clean slate of completions
1967 # Start with a clean slate of completions
1965 matches = []
1968 matches = []
@@ -2006,7 +2009,8 b' class IPCompleter(Completer):'
2006 seen.add(t)
2009 seen.add(t)
2007
2010
2008 _filtered_matches = sorted(
2011 _filtered_matches = sorted(
2009 set(filtered_matches), key=lambda x: completions_sorting_key(x[0]))
2012 set(filtered_matches), key=lambda x: completions_sorting_key(x[0]))\
2013 [:MATCHES_LIMIT]
2010
2014
2011 _matches = [m[0] for m in _filtered_matches]
2015 _matches = [m[0] for m in _filtered_matches]
2012 origins = [m[1] for m in _filtered_matches]
2016 origins = [m[1] for m in _filtered_matches]
General Comments 0
You need to be logged in to leave comments. Login now