[ruby/reline] Implement em_kill_line
https://github.com/ruby/reline/commit/9fca6ceb45
This commit is contained in:
parent
6c3cc9c58a
commit
bad1e153d4
@ -2632,6 +2632,17 @@ class Reline::LineEditor
|
|||||||
end
|
end
|
||||||
alias_method :unix_line_discard, :vi_kill_line_prev
|
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)
|
private def em_delete(key)
|
||||||
if (not @is_multiline and @line.empty?) or (@is_multiline and @line.empty? and @buffer_of_lines.size == 1)
|
if (not @is_multiline and @line.empty?) or (@is_multiline and @line.empty? and @buffer_of_lines.size == 1)
|
||||||
@line = nil
|
@line = nil
|
||||||
|
@ -254,6 +254,34 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
|
|||||||
assert_line('ab')
|
assert_line('ab')
|
||||||
end
|
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
|
def test_ed_move_to_beg
|
||||||
input_keys('abd')
|
input_keys('abd')
|
||||||
assert_byte_pointer_size('abd')
|
assert_byte_pointer_size('abd')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user