Show More
@@ -886,8 +886,7 b' class IPCompleter(Completer):' | |||
|
886 | 886 | # parenthesis before the cursor |
|
887 | 887 | # e.g. for "foo (1+bar(x), pa<cursor>,a=1)", the candidate is "foo" |
|
888 | 888 | tokens = regexp.findall(self.text_until_cursor) |
|
889 |
tokens |
|
|
890 | iterTokens = iter(tokens); openPar = 0 | |
|
889 | iterTokens = reversed(tokens); openPar = 0 | |
|
891 | 890 | |
|
892 | 891 | for token in iterTokens: |
|
893 | 892 | if token == ')': |
@@ -912,6 +911,25 b' class IPCompleter(Completer):' | |||
|
912 | 911 | break |
|
913 | 912 | except StopIteration: |
|
914 | 913 | break |
|
914 | ||
|
915 | # Find all named arguments already assigned to, as to avoid suggesting | |
|
916 | # them again | |
|
917 | usedNamedArgs = set() | |
|
918 | par_level = -1 | |
|
919 | for token, next_token in itertools.izip(tokens, tokens[1:]): | |
|
920 | if token == '(': | |
|
921 | par_level += 1 | |
|
922 | elif token == ')': | |
|
923 | par_level -= 1 | |
|
924 | ||
|
925 | if par_level != 0: | |
|
926 | continue | |
|
927 | ||
|
928 | if next_token != '=': | |
|
929 | continue | |
|
930 | ||
|
931 | usedNamedArgs.add(token) | |
|
932 | ||
|
915 | 933 | # lookup the candidate callable matches either using global_matches |
|
916 | 934 | # or attr_matches for dotted names |
|
917 | 935 | if len(ids) == 1: |
@@ -926,7 +944,8 b' class IPCompleter(Completer):' | |||
|
926 | 944 | except: |
|
927 | 945 | continue |
|
928 | 946 | |
|
929 | for namedArg in namedArgs: | |
|
947 | # Remove used named arguments from the list, no need to show twice | |
|
948 | for namedArg in set(namedArgs) - usedNamedArgs: | |
|
930 | 949 | if namedArg.startswith(text): |
|
931 | 950 | argMatches.append(u"%s=" %namedArg) |
|
932 | 951 | return argMatches |
General Comments 0
You need to be logged in to leave comments.
Login now