Skip to content

Commit 06b9400

Browse files
formatting and tests
1 parent 4a43c11 commit 06b9400

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

bpython/curtsiesfrontend/repl.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -547,17 +547,15 @@ def process_key_event(self, e):
547547
def get_last_word(self):
548548

549549
def last_word(line):
550-
if not line:
551-
return ''
552-
return line.split().pop()
550+
return line.split().pop() if line else ''
553551

554552
previous_word = last_word(self.rl_history.entry)
555553
word = last_word(self.rl_history.back())
556-
line=self.current_line
557-
self._set_current_line(line[:len(line)-len(previous_word)]+word, reset_rl_history=False)
558-
559-
self._set_cursor_offset(self.cursor_offset-len(previous_word)+len(word), reset_rl_history=False)
560-
554+
line = self.current_line
555+
self._set_current_line(line[:len(line)-len(previous_word)] + word,
556+
reset_rl_history=False)
557+
self._set_cursor_offset(self.cursor_offset-len(previous_word) + len(word),
558+
reset_rl_history=False)
561559

562560
def incremental_search(self, reverse=False, include_current=False):
563561
if self.special_mode == None:

bpython/test/test_curtsies_painting.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ def assert_paint_ignoring_formatting(self, screen, cursor_row_col=None):
4040
if cursor_row_col is not None:
4141
self.assertEqual(cursor_pos, cursor_row_col)
4242

43+
class TestCurtsiesPaintingTest(TestCurtsiesPainting):
44+
45+
def test_history_is_cleared(self):
46+
self.assertEqual(self.repl.rl_history.entries, [''])
47+
4348
class TestCurtsiesPaintingSimple(TestCurtsiesPainting):
4449

4550
def test_startup(self):

0 commit comments

Comments
 (0)