Skip to content

Commit

Permalink
[ruby/reline] Rename the wrong name "em-kill-line" with the correct n…
Browse files Browse the repository at this point in the history
…ame "unix-line-discard"

ruby/reline@da7af35d1f
  • Loading branch information
aycabta committed Dec 24, 2021
1 parent fd60a23 commit 6c3cc9c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/reline/line_editor.rb
Expand Up @@ -2616,11 +2616,12 @@ def finish
end
alias_method :kill_line, :ed_kill_line

# Editline:: +em-kill-line+ (not bound) Delete the entire contents of the
# edit buffer and save it to the cut buffer. +vi-kill-line-prev+
# Editline:: +vi-kill-line-prev+ (vi: +Ctrl-U+) Delete the string from the
# beginning of the edit buffer to the cursor and save it to the
# cut buffer.
# GNU Readline:: +unix-line-discard+ (+C-u+) Kill backward from the cursor
# to the beginning of the current line.
private def em_kill_line(key)
private def vi_kill_line_prev(key)
if @byte_pointer > 0
@line, deleted = byteslice!(@line, 0, @byte_pointer)
@byte_pointer = 0
Expand All @@ -2629,8 +2630,7 @@ def finish
@cursor = 0
end
end
alias_method :unix_line_discard, :em_kill_line
alias_method :vi_kill_line_prev, :em_kill_line
alias_method :unix_line_discard, :vi_kill_line_prev

private def em_delete(key)
if (not @is_multiline and @line.empty?) or (@is_multiline and @line.empty? and @buffer_of_lines.size == 1)
Expand Down
28 changes: 28 additions & 0 deletions test/reline/test_key_actor_vi.rb
Expand Up @@ -1426,4 +1426,32 @@ def test_ed_delete_next_char_at_eol
assert_cursor(4)
assert_cursor_max(4)
end

def test_vi_kill_line_prev
input_keys("\C-u", false)
assert_byte_pointer_size('')
assert_cursor(0)
assert_cursor_max(0)
assert_line('')
input_keys('abc')
assert_byte_pointer_size('abc')
assert_cursor(3)
assert_cursor_max(3)
input_keys("\C-u", false)
assert_byte_pointer_size('')
assert_cursor(0)
assert_cursor_max(0)
assert_line('')
input_keys('abc')
input_keys("\C-[\C-u", false)
assert_byte_pointer_size('')
assert_cursor(0)
assert_cursor_max(1)
assert_line('c')
input_keys("\C-u", false)
assert_byte_pointer_size('')
assert_cursor(0)
assert_cursor_max(1)
assert_line('c')
end
end

0 comments on commit 6c3cc9c

Please sign in to comment.