Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Simply drop out of search mode (back to the original mode) when accepting an empty search-string.
  • Loading branch information
mbauman committed Jul 10, 2014
1 parent c5cf785 commit 8f897cf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
10 changes: 7 additions & 3 deletions base/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,13 @@ end
function LineEdit.accept_result(s, p::LineEdit.HistoryPrompt{REPLHistoryProvider})
parent = LineEdit.state(s, p).parent
hist = p.hp
m = hist.mode_mapping[hist.modes[hist.cur_idx]]
LineEdit.replace_line(LineEdit.state(s, m), LineEdit.state(s, p).response_buffer)
LineEdit.transition(s, m)
if 1 <= hist.cur_idx <= length(hist.modes)
m = hist.mode_mapping[hist.modes[hist.cur_idx]]
LineEdit.replace_line(LineEdit.state(s, m), LineEdit.state(s, p).response_buffer)
LineEdit.transition(s, m)
else
LineEdit.transition(s, parent)
end
end

function history_prev(s::LineEdit.MIState, hist::REPLHistoryProvider,
Expand Down
10 changes: 10 additions & 0 deletions test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,16 @@ begin
LineEdit.accept_result(s, histp)
@test LineEdit.mode(s) == shell_mode
@test buffercontents(LineEdit.buffer(s)) == "ll"

# Issue #7551
# Enter search mode and try accepting an empty result
REPL.history_reset_state(hp)
LineEdit.edit_clear(s)
cur_mode = LineEdit.mode(s)
LineEdit.enter_search(s, histp, true)
LineEdit.accept_result(s, histp)
@test LineEdit.mode(s) == cur_mode
@test buffercontents(LineEdit.buffer(s)) == ""
end

ccall(:jl_exit_on_sigint, Void, (Cint,), 1)
Expand Down

0 comments on commit 8f897cf

Please sign in to comment.