mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parent
6c3cc9c58a
commit
bad1e153d4
2 changed files with 39 additions and 0 deletions
|
@ -2632,6 +2632,17 @@ class Reline::LineEditor
|
|||
end
|
||||
alias_method :unix_line_discard, :vi_kill_line_prev
|
||||
|
||||
private def em_kill_line(key)
|
||||
if @line.size > 0
|
||||
@kill_ring.append(@line.dup, true)
|
||||
@line.clear
|
||||
@byte_pointer = 0
|
||||
@cursor_max = 0
|
||||
@cursor = 0
|
||||
end
|
||||
end
|
||||
alias_method :kill_whole_line, :em_kill_line
|
||||
|
||||
private def em_delete(key)
|
||||
if (not @is_multiline and @line.empty?) or (@is_multiline and @line.empty? and @buffer_of_lines.size == 1)
|
||||
@line = nil
|
||||
|
|
|
@ -254,6 +254,34 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
|
|||
assert_line('ab')
|
||||
end
|
||||
|
||||
def test_em_kill_line
|
||||
@line_editor.input_key(Reline::Key.new(:em_kill_line, :em_kill_line, false))
|
||||
assert_byte_pointer_size('')
|
||||
assert_cursor(0)
|
||||
assert_cursor_max(0)
|
||||
assert_line('')
|
||||
input_keys('abc')
|
||||
@line_editor.input_key(Reline::Key.new(:em_kill_line, :em_kill_line, false))
|
||||
assert_byte_pointer_size('')
|
||||
assert_cursor(0)
|
||||
assert_cursor_max(0)
|
||||
assert_line('')
|
||||
input_keys('abc')
|
||||
input_keys("\C-b", false)
|
||||
@line_editor.input_key(Reline::Key.new(:em_kill_line, :em_kill_line, false))
|
||||
assert_byte_pointer_size('')
|
||||
assert_cursor(0)
|
||||
assert_cursor_max(0)
|
||||
assert_line('')
|
||||
input_keys('abc')
|
||||
input_keys("\C-a", false)
|
||||
@line_editor.input_key(Reline::Key.new(:em_kill_line, :em_kill_line, false))
|
||||
assert_byte_pointer_size('')
|
||||
assert_cursor(0)
|
||||
assert_cursor_max(0)
|
||||
assert_line('')
|
||||
end
|
||||
|
||||
def test_ed_move_to_beg
|
||||
input_keys('abd')
|
||||
assert_byte_pointer_size('abd')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue