Skip to content

Commit

Permalink
Bind yank-pop correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed Dec 18, 2020
1 parent e6dbcb3 commit 3c74bea
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/reline/key_actor/emacs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ class Reline::KeyActor::Emacs < Reline::KeyActor::Base
# 152 M-^X
:ed_unassigned,
# 153 M-^Y
:ed_unassigned,
:em_yank_pop,
# 154 M-^Z
:ed_unassigned,
# 155 M-^[
Expand Down
2 changes: 2 additions & 0 deletions lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1991,6 +1991,7 @@ def finish
@byte_pointer += yanked.bytesize
end
end
alias_method :yank, :em_yank

private def em_yank_pop(key)
yanked, prev_yank = @kill_ring.yank_pop
Expand All @@ -2007,6 +2008,7 @@ def finish
@byte_pointer += yanked.bytesize
end
end
alias_method :yank_pop, :em_yank_pop

private def ed_clear_screen(key)
@cleared = true
Expand Down
18 changes: 18 additions & 0 deletions test/reline/test_key_actor_emacs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2167,6 +2167,24 @@ def test_ed_insert_for_include_valiation_selector
end
end

def test_em_yank_pop
input_keys("def hoge\C-w\C-b\C-f\C-w", false)
assert_byte_pointer_size('')
assert_cursor(0)
assert_cursor_max(0)
assert_line('')
input_keys("\C-y", false)
assert_byte_pointer_size('def ')
assert_cursor(4)
assert_cursor_max(4)
assert_line('def ')
input_keys("\M-\C-y", false)
assert_byte_pointer_size('hoge')
assert_cursor(4)
assert_cursor_max(4)
assert_line('hoge')
end

=begin # TODO: move KeyStroke instance from Reline to LineEditor
def test_key_delete
input_keys('ab')
Expand Down

0 comments on commit 3c74bea

Please sign in to comment.