Skip to content

Commit da7af35

Browse files
committed
Rename the wrong name "em-kill-line" with the correct name "unix-line-discard"
1 parent 9ab9957 commit da7af35

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

lib/reline/line_editor.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2536,11 +2536,12 @@ def finish
25362536
end
25372537
alias_method :kill_line, :ed_kill_line
25382538

2539-
# Editline:: +em-kill-line+ (not bound) Delete the entire contents of the
2540-
# edit buffer and save it to the cut buffer. +vi-kill-line-prev+
2539+
# Editline:: +vi-kill-line-prev+ (vi: +Ctrl-U+) Delete the string from the
2540+
# beginning of the edit buffer to the cursor and save it to the
2541+
# cut buffer.
25412542
# GNU Readline:: +unix-line-discard+ (+C-u+) Kill backward from the cursor
25422543
# to the beginning of the current line.
2543-
private def em_kill_line(key)
2544+
private def vi_kill_line_prev(key)
25442545
if @byte_pointer > 0
25452546
@line, deleted = byteslice!(@line, 0, @byte_pointer)
25462547
@byte_pointer = 0
@@ -2549,8 +2550,7 @@ def finish
25492550
@cursor = 0
25502551
end
25512552
end
2552-
alias_method :unix_line_discard, :em_kill_line
2553-
alias_method :vi_kill_line_prev, :em_kill_line
2553+
alias_method :unix_line_discard, :vi_kill_line_prev
25542554

25552555
private def em_delete(key)
25562556
if (not @is_multiline and @line.empty?) or (@is_multiline and @line.empty? and @buffer_of_lines.size == 1)

test/reline/test_key_actor_vi.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,4 +1426,32 @@ def test_ed_delete_next_char_at_eol
14261426
assert_cursor(4)
14271427
assert_cursor_max(4)
14281428
end
1429+
1430+
def test_vi_kill_line_prev
1431+
input_keys("\C-u", false)
1432+
assert_byte_pointer_size('')
1433+
assert_cursor(0)
1434+
assert_cursor_max(0)
1435+
assert_line('')
1436+
input_keys('abc')
1437+
assert_byte_pointer_size('abc')
1438+
assert_cursor(3)
1439+
assert_cursor_max(3)
1440+
input_keys("\C-u", false)
1441+
assert_byte_pointer_size('')
1442+
assert_cursor(0)
1443+
assert_cursor_max(0)
1444+
assert_line('')
1445+
input_keys('abc')
1446+
input_keys("\C-[\C-u", false)
1447+
assert_byte_pointer_size('')
1448+
assert_cursor(0)
1449+
assert_cursor_max(1)
1450+
assert_line('c')
1451+
input_keys("\C-u", false)
1452+
assert_byte_pointer_size('')
1453+
assert_cursor(0)
1454+
assert_cursor_max(1)
1455+
assert_line('c')
1456+
end
14291457
end

0 commit comments

Comments
 (0)