Skip to content

Commit

Permalink
Old REPL behavior navigating history with up/down keys
Browse files Browse the repository at this point in the history
  • Loading branch information
carlobaldassi committed Mar 31, 2014
1 parent 2863c89 commit 484a467
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions base/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ function history_prev(s,hist)
(l,ok) = history_prev(mode(s).hist)
if ok
replace_line(s,l)
refresh_line(s)
move_input_start(s)
else
beep(LineEdit.terminal(s))
end
Expand All @@ -554,7 +554,7 @@ function history_next(s,hist)
(l,ok) = history_next(mode(s).hist)
if ok
replace_line(s,l)
refresh_line(s)
move_input_end(s)
else
beep(LineEdit.terminal(s))
end
Expand Down
11 changes: 6 additions & 5 deletions base/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ function history_prev(s::LineEdit.MIState,hist::REPLHistoryProvider)
hist.cur_idx-=1
LineEdit.transition(s,hist.mode_mapping[hist.modes[hist.cur_idx]])
LineEdit.replace_line(s,hist.history[hist.cur_idx])
LineEdit.refresh_line(s)
LineEdit.move_input_start(s)
LineEdit.move_line_end(s)
else
Terminals.beep(LineEdit.terminal(s))
end
Expand All @@ -268,23 +269,23 @@ function history_next(s::LineEdit.MIState,hist::REPLHistoryProvider)
hist.cur_idx+=1
LineEdit.transition(s,hist.mode_mapping[hist.modes[hist.cur_idx]])
LineEdit.replace_line(s,hist.history[hist.cur_idx])
LineEdit.refresh_line(s)
LineEdit.move_input_end(s)
elseif hist.cur_idx == length(hist.history)
hist.cur_idx+=1
buf = hist.last_buffer
hist.last_buffer = IOBuffer()
LineEdit.transition(s,hist.last_mode)
LineEdit.replace_line(s,buf)
LineEdit.refresh_line(s)
LineEdit.move_input_end(s)
elseif 0 < hist.last_idx < length(hist.history)
# issue #6321
# issue #6312
hist.cur_idx = hist.last_idx + 1
hist.last_idx = -1
hist.last_mode = LineEdit.mode(s)
hist.last_buffer = copy(LineEdit.buffer(s))
LineEdit.transition(s,hist.mode_mapping[hist.modes[hist.cur_idx]])
LineEdit.replace_line(s,hist.history[hist.cur_idx])
LineEdit.refresh_line(s)
LineEdit.move_input_end(s)
else
Terminals.beep(LineEdit.terminal(s))
end
Expand Down

0 comments on commit 484a467

Please sign in to comment.