@@ -267,7 +267,7 @@ def smarter_request_reload(desc):
267267 self .interact = self .status_bar # overwriting what bpython.Repl put there
268268 # interact is called to interact with the status bar,
269269 # so we're just using the same object
270- self .current_line = '' # line currently being edited, without '>>> '
270+ self ._current_line = '' # line currently being edited, without '>>> '
271271 self .current_stdouterr_line = '' # current line of output - stdout and stdin go here
272272 self .display_lines = [] # lines separated whenever logical line
273273 # length goes over what the terminal width
@@ -280,7 +280,7 @@ def smarter_request_reload(desc):
280280 # bpython.Repl
281281 self .scroll_offset = 0 # how many times display has been scrolled down
282282 # because there wasn't room to display everything
283- self .cursor_offset = 0 # from the left, 0 means first char
283+ self ._cursor_offset = 0 # from the left, 0 means first char
284284 self .orig_tcattrs = orig_tcattrs # useful for shelling out with normal terminal
285285
286286 self .coderunner = CodeRunner (self .interp , self .request_refresh )
@@ -407,21 +407,18 @@ def proccess_control_event(self, e):
407407 self .stdin .process_event (ee )
408408 else :
409409 self .process_simple_keypress (ee )
410- self .update_completion ()
411410
412411 elif self .stdin .has_focus :
413412 return self .stdin .process_event (e )
414413
415414 elif isinstance (e , events .SigIntEvent ):
416415 logger .debug ('received sigint event' )
417416 self .keyboard_interrupt ()
418- self .update_completion ()
419417 return
420418
421419 elif isinstance (e , events .ReloadEvent ):
422420 if self .watching_files :
423421 self .clear_modules_and_reevaluate ()
424- self .update_completion ()
425422 self .status_bar .message ('Reloaded at ' + time .strftime ('%H:%M:%S' ) + ' because ' + ' & ' .join (e .files_modified ) + ' modified' )
426423
427424 else :
@@ -451,18 +448,15 @@ def process_key_event(self, e):
451448
452449 elif e in key_dispatch [self .config .reimport_key ]:
453450 self .clear_modules_and_reevaluate ()
454- self .update_completion ()
455451 self .status_bar .message ('Reloaded at ' + time .strftime ('%H:%M:%S' ) + ' by user' )
456452
457453 elif (e in ("<RIGHT>" , '<Ctrl-f>' ) and self .config .curtsies_right_arrow_completion
458454 and self .cursor_offset == len (self .current_line )):
459455 self .current_line += self .current_suggestion
460456 self .cursor_offset = len (self .current_line )
461- self .update_completion ()
462457
463458 elif e in self .rl_char_sequences :
464459 self .cursor_offset , self .current_line = self .rl_char_sequences [e ](self .cursor_offset , self .current_line )
465- self .update_completion ()
466460 self .rl_history .reset ()
467461
468462 # readline history commands
@@ -510,7 +504,6 @@ def process_key_event(self, e):
510504 raise SystemExit ()
511505 else :
512506 self .current_line = self .current_line [:self .cursor_offset ] + self .current_line [self .cursor_offset + 1 :]
513- self .update_completion ()
514507 self .rl_history .reset ()
515508 elif e in key_dispatch [self .config .exit_key ]:
516509 raise SystemExit ()
@@ -524,7 +517,6 @@ def process_key_event(self, e):
524517 self .rl_history .reset ()
525518 elif e in key_dispatch [self .config .undo_key ]: #ctrl-r for undo
526519 self .undo ()
527- self .update_completion ()
528520 elif e in key_dispatch [self .config .save_key ]: # ctrl-s for save
529521 g = greenlet .greenlet (self .write2file )
530522 g .switch ()
@@ -541,11 +533,9 @@ def process_key_event(self, e):
541533 pass
542534 elif e in ["<SPACE>" ]:
543535 self .add_normal_character (' ' )
544- self .update_completion ()
545536 else :
546537 self .add_normal_character (e )
547538 self .rl_history .reset ()
548- self .update_completion ()
549539
550540 def on_enter (self , insert_into_history = True ):
551541 self .cursor_offset = - 1 # so the cursor isn't touching a paren
@@ -587,14 +577,16 @@ def only_whitespace_left_of_cursor():
587577
588578 # 3. check to see if we can expand the current word
589579 if self .matches_iter .is_cseq ():
590- self .cursor_offset , self .current_line = self .matches_iter .substitute_cseq ()
580+ self ._cursor_offset , self ._current_line = self .matches_iter .substitute_cseq ()
581+ # using _current_line so we don't trigger a completion reset
591582 if not self .matches_iter :
592583 self .list_win_visible = self .complete ()
593584
594585 elif self .matches_iter .matches :
595586 self .current_match = back and self .matches_iter .previous () \
596587 or self .matches_iter .next ()
597- self .cursor_offset , self .current_line = self .matches_iter .cur_line ()
588+ self ._cursor_offset , self ._current_line = self .matches_iter .cur_line ()
589+ # using _current_line so we don't trigger a completion reset
598590
599591 def process_simple_keypress (self , e ):
600592 if e in (u"<Ctrl-j>" , u"<Ctrl-m>" , u"<PADENTER>" ):
@@ -661,6 +653,7 @@ def update_completion(self, tab=False):
661653 # * when current line changes, unless via selecting a match
662654 # * when cursor position changes
663655 # *
656+ self .current_match = None
664657 self .list_win_visible = BpythonRepl .complete (self , tab )
665658 #look for history stuff
666659
@@ -733,7 +726,6 @@ def run_code_and_maybe_finish(self, for_code=None):
733726
734727 self .current_line = ' ' * indent
735728 self .cursor_offset = len (self .current_line )
736- self .update_completion ()
737729
738730 def keyboard_interrupt (self ):
739731 #TODO factor out the common cleanup from running a line
@@ -1052,6 +1044,20 @@ def __repr__(self):
10521044 s += '>'
10531045 return s
10541046
1047+ def _get_current_line (self ):
1048+ return self ._current_line
1049+ def _set_current_line (self , line ):
1050+ self ._current_line = line
1051+ self .update_completion ()
1052+ current_line = property (_get_current_line , _set_current_line , None ,
1053+ "The current line" )
1054+ def _get_cursor_offset (self ):
1055+ return self ._cursor_offset
1056+ def _set_cursor_offset (self , line ):
1057+ self ._cursor_offset = line
1058+ self .update_completion ()
1059+ cursor_offset = property (_get_cursor_offset , _set_cursor_offset , None ,
1060+ "The current cursor offset from the front of the line" )
10551061 def echo (self , msg , redraw = True ):
10561062 """
10571063 Notification that redrawing the current line is necessary (we don't
0 commit comments