File tree Expand file tree Collapse file tree 1 file changed +10
-15
lines changed
Expand file tree Collapse file tree 1 file changed +10
-15
lines changed Original file line number Diff line number Diff line change @@ -532,24 +532,19 @@ def process_key_event(self, e):
532532 self .add_normal_character (e )
533533
534534 def get_last_word (self ):
535- entry = self .rl_history .entry
536535
537- self .current_line = self .current_line [:- len (entry )]
538-
539- self ._set_cursor_offset (self .cursor_offset - len (entry ))
540-
541- last_history_entry = self .rl_history .back ()
542-
543- last_word = last_history_entry .split ().pop ()
544-
545- # print 'first', self.cursor_offset
546- self .current_line = self .current_line + last_word
536+ def last_word (line ):
537+ if not line :
538+ return ''
539+ return line .split ().pop ()
547540
548- self ._set_cursor_offset (self .cursor_offset + len (last_word ))
549- #print len(self.rl_history.entry)
541+ previous_word = last_word (self .rl_history .entry )
542+ word = last_word (self .rl_history .back ())
543+ line = self .current_line
544+ self ._set_current_line (line [:len (line )- len (previous_word )]+ word , reset_rl_history = False )
550545
551- # self._set_cursor_offset(remember_cursor_offset )
552- # print 'second', self.cursor_offset
546+ self ._set_cursor_offset (self . cursor_offset - len ( previous_word ) + len ( word ), reset_rl_history = False )
547+
553548
554549 def incremental_search (self , reverse = False , include_current = False ):
555550 if self .special_mode == None :
You can’t perform that action at this time.
0 commit comments