Skip to content

Commit

Permalink
REPL: fix edit_yank_pop when require_previous_yank=false (JuliaLang#2…
Browse files Browse the repository at this point in the history
  • Loading branch information
rfourquet committed Sep 9, 2017
1 parent c173ae0 commit e16f4dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions base/repl/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -684,11 +684,12 @@ function edit_yank(s::MIState)
end

function edit_yank_pop(s::MIState, require_previous_yank=true)
if require_previous_yank && !(s.last_action in [:edit_yank, :edit_yank_pop]) ||
isempty(s.kill_ring)
repeat = s.last_action (:edit_yank, :edit_yank_pop)
if require_previous_yank && !repeat || isempty(s.kill_ring)
beep(terminal(s))
:ignore
else
require_previous_yank || repeat || setmark(s)
push_undo(s)
edit_splice!(s, s.kill_ring[mod1(s.kill_idx-=1, end)])
refresh_line(s)
Expand Down
4 changes: 4 additions & 0 deletions test/lineedit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,10 @@ end
LineEdit.edit_kill_line(s)
@test s.kill_ring[end] == "çhing"
@test s.kill_idx == 3
# check that edit_yank_pop works when passing require_previous_yank=false (#23635)
s.last_action = :unknown
@test transform!(s->LineEdit.edit_yank_pop(s, false), s) == ("ça ≡ nothinga ≡ not", 19, 12)

# repetition (concatenation of killed strings
edit_insert(s, "A B C")
LineEdit.edit_delete_prev_word(s)
Expand Down

0 comments on commit e16f4dc

Please sign in to comment.