@@ -465,7 +465,7 @@ def startup(self):
465465
466466 def current_string (self , concatenate = False ):
467467 """If the line ends in a string get it, otherwise return ''"""
468- tokens = self .tokenize (self .current_line () )
468+ tokens = self .tokenize (self .current_line )
469469 string_tokens = list (takewhile (token_is_any_of ([Token .String ,
470470 Token .Text ]),
471471 reversed (tokens )))
@@ -515,7 +515,7 @@ def get_args(self):
515515 stack = [['' , 0 , '' ]]
516516 try :
517517 for (token , value ) in PythonLexer ().get_tokens (
518- self .current_line () ):
518+ self .current_line ):
519519 if token is Token .Punctuation :
520520 if value in '([{' :
521521 stack .append (['' , 0 , value ])
@@ -576,7 +576,7 @@ def get_source_of_current_name(self):
576576 try :
577577 obj = self .current_func
578578 if obj is None :
579- line = self .current_line ()
579+ line = self .current_line
580580 if inspection .is_eval_safe_name (line ):
581581 obj = self .get_object (line )
582582 source = inspect .getsource (obj )
@@ -603,7 +603,7 @@ def set_docstring(self):
603603 def magic_method_completions (self , cw ):
604604 if (self .config .complete_magic_methods and self .buffer and
605605 self .buffer [0 ].startswith ("class " ) and
606- self .current_line () .lstrip ().startswith ("def " )):
606+ self .current_line .lstrip ().startswith ("def " )):
607607 return [name for name in self .config .magic_methods
608608 if name .startswith (cw )]
609609 else :
@@ -618,27 +618,22 @@ def complete(self, tab=False):
618618 self .set_docstring ()
619619
620620 matches , completer = autocomplete .get_completer (
621- len ( self .current_line ()) - self . cpos ,
622- self .current_line () ,
621+ self .cursor_offset ,
622+ self .current_line ,
623623 self .interp .locals ,
624624 self .argspec ,
625625 self .config ,
626626 self .magic_method_completions )
627627
628- if matches is None : # no completion is relevant
628+ if (matches is None # no completion is relevant
629+ or len (matches ) == 0 ): # some completion works, but no matches
629630 self .matches_iter .clear ()
630631 return bool (self .argspec )
631632
632- elif len (matches ) == 0 : # some completion works, but no matches
633- self .matches_iter .update (len (self .current_line ()) - self .cpos ,
634- self .current_line (),
635- matches , completer )
636- return bool (self .argspec )
633+ self .matches_iter .update (self .cursor_offset ,
634+ self .current_line , matches , completer )
637635
638- elif len (matches ) == 1 :
639- self .matches_iter .update (len (self .current_line ()) - self .cpos ,
640- self .current_line (),
641- matches , completer )
636+ if len (matches ) == 1 :
642637 self .matches_iter .next ()
643638 if tab : # if this complete is being run for a tab key press, tab() to do the swap
644639 self .tab ()
@@ -650,8 +645,6 @@ def complete(self, tab=False):
650645 return True
651646
652647 else :
653- self .matches_iter .update (len (self .current_line ()) - self .cpos ,
654- self .current_line (), matches , completer )
655648 return True
656649
657650 def format_docstring (self , docstring , width , height ):
0 commit comments