| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3332f4f commit b51663c
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -628,11 +628,8 @@ def process_key_event(self, e): | |||
| 628 | 628 | ||
| 629 | 629 | def get_last_word(self): | |
| 630 | 630 | ||
| 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()) | ||
| 636 | 633 | line = self.current_line | |
| 637 | 634 | self._set_current_line(line[:len(line) - len(previous_word)] + word, | |
| 638 | 635 | reset_rl_history=False) | |
@@ -1522,6 +1519,10 @@ def tabs_to_spaces(line): | |||
| 1522 | 1519 | return line.replace('\t', ' ') | |
| 1523 | 1520 | ||
| 1524 | 1521 | ||
| 1522 | + def _last_word(line): | ||
| 1523 | + return line.split().pop() if line else '' | ||
| 1524 | + | ||
| 1525 | + | ||
| 1525 | 1526 | def compress_paste_event(paste_event): | |
| 1526 | 1527 | """If all events in a paste event are identical and not simple characters, | |
| 1527 | 1528 | returns one of them | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -77,6 +77,12 @@ def test_get_last_word(self): | |||
| 77 | 77 | self.repl.get_last_word() | |
| 78 | 78 | self.assertEqual(self.repl.current_line, 'abcde3') | |
| 79 | 79 | ||
| 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 | + | ||
| 80 | 86 | # this is the behavior of bash - not currently implemented | |
| 81 | 87 | @unittest.skip | |
| 82 | 88 | def test_get_last_word_with_prev_line(self): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments