File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -628,11 +628,8 @@ def process_key_event(self, e):
628628
629629 def get_last_word (self ):
630630
631- def last_word (line ):
632- return line .split ().pop () if line else ''
633-
634- previous_word = last_word (self .rl_history .entry )
635- word = last_word (self .rl_history .back ())
631+ previous_word = _last_word (self .rl_history .entry )
632+ word = _last_word (self .rl_history .back ())
636633 line = self .current_line
637634 self ._set_current_line (line [:len (line ) - len (previous_word )] + word ,
638635 reset_rl_history = False )
@@ -1522,6 +1519,10 @@ def tabs_to_spaces(line):
15221519 return line .replace ('\t ' , ' ' )
15231520
15241521
1522+ def _last_word (line ):
1523+ return line .split ().pop () if line else ''
1524+
1525+
15251526def compress_paste_event (paste_event ):
15261527 """If all events in a paste event are identical and not simple characters,
15271528 returns one of them
Original file line number Diff line number Diff line change @@ -77,6 +77,12 @@ def test_get_last_word(self):
7777 self .repl .get_last_word ()
7878 self .assertEqual (self .repl .current_line , 'abcde3' )
7979
80+ def test_last_word (self ):
81+ self .assertEquals (curtsiesrepl ._last_word ('' ), '' )
82+ self .assertEquals (curtsiesrepl ._last_word (' ' ), '' )
83+ self .assertEquals (curtsiesrepl ._last_word ('a' ), 'a' )
84+ self .assertEquals (curtsiesrepl ._last_word ('a b' ), 'b' )
85+
8086 # this is the behavior of bash - not currently implemented
8187 @unittest .skip
8288 def test_get_last_word_with_prev_line (self ):
You can’t perform that action at this time.
0 commit comments