Skip to content

Commit eb3b8f3

Browse files
PeriGKthomasballinger
authored andcommitted
Implementing code review changes.
1 parent e04e0f2 commit eb3b8f3

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

bpython/curtsiesfrontend/repl.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ def process_key_event(self, e):
676676
elif e in ("<Ctrl-d>",):
677677
self.on_control_d()
678678
elif e in ("<Ctrl-o>",):
679-
self.on_control_o()
679+
self.operate_and_get_next()
680680
elif e in ("<Esc+.>",):
681681
self.get_last_word()
682682
elif e in key_dispatch[self.config.reverse_incremental_search_key]:
@@ -846,20 +846,25 @@ def on_control_d(self):
846846
self.current_line = (self.current_line[:self.cursor_offset] +
847847
self.current_line[(self.cursor_offset + 1):])
848848

849-
def on_control_o(self):
850-
next_idx = -self.rl_history.index + 1
851-
next = self.rl_history.entries[next_idx]
852-
self.on_enter()
853-
print("Next is : " + next)
854-
self._set_current_line(next)
855-
856849
def cut_to_buffer(self):
857850
self.cut_buffer = self.current_line[self.cursor_offset:]
858851
self.current_line = self.current_line[:self.cursor_offset]
859852

860853
def yank_from_buffer(self):
861854
pass
862855

856+
def operate_and_get_next(self):
857+
# If we have not navigated back in history
858+
# ctrl+o will have the same effect as enter
859+
if self.rl_history.index == 0 or self.rl_history.index == 1:
860+
self.on_enter()
861+
return
862+
863+
index = self.rl_history.index
864+
self.on_enter()
865+
self.rl_history.index = index
866+
self._set_current_line(self.rl_history.entries[-index], reset_rl_history=False)
867+
863868
def up_one_line(self):
864869
self.rl_history.enter(self.current_line)
865870
self._set_current_line(tabs_to_spaces(self.rl_history.back(

0 commit comments

Comments
 (0)