Skip to content

Commit e16f4dc

Browse files
authored
REPL: fix edit_yank_pop when require_previous_yank=false (#23635)
1 parent c173ae0 commit e16f4dc

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

base/repl/LineEdit.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,11 +684,12 @@ function edit_yank(s::MIState)
684684
end
685685

686686
function edit_yank_pop(s::MIState, require_previous_yank=true)
687-
if require_previous_yank && !(s.last_action in [:edit_yank, :edit_yank_pop]) ||
688-
isempty(s.kill_ring)
687+
repeat = s.last_action (:edit_yank, :edit_yank_pop)
688+
if require_previous_yank && !repeat || isempty(s.kill_ring)
689689
beep(terminal(s))
690690
:ignore
691691
else
692+
require_previous_yank || repeat || setmark(s)
692693
push_undo(s)
693694
edit_splice!(s, s.kill_ring[mod1(s.kill_idx-=1, end)])
694695
refresh_line(s)

test/lineedit.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,10 @@ end
617617
LineEdit.edit_kill_line(s)
618618
@test s.kill_ring[end] == "çhing"
619619
@test s.kill_idx == 3
620+
# check that edit_yank_pop works when passing require_previous_yank=false (#23635)
621+
s.last_action = :unknown
622+
@test transform!(s->LineEdit.edit_yank_pop(s, false), s) == ("ça ≡ nothinga ≡ not", 19, 12)
623+
620624
# repetition (concatenation of killed strings
621625
edit_insert(s, "A B C")
622626
LineEdit.edit_delete_prev_word(s)

0 commit comments

Comments
 (0)