File tree Expand file tree Collapse file tree 2 files changed +33
-5
lines changed Expand file tree Collapse file tree 2 files changed +33
-5
lines changed Original file line number Diff line number Diff line change @@ -2536,11 +2536,12 @@ def finish
2536
2536
end
2537
2537
alias_method :kill_line , :ed_kill_line
2538
2538
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.
2541
2542
# GNU Readline:: +unix-line-discard+ (+C-u+) Kill backward from the cursor
2542
2543
# to the beginning of the current line.
2543
- private def em_kill_line ( key )
2544
+ private def vi_kill_line_prev ( key )
2544
2545
if @byte_pointer > 0
2545
2546
@line , deleted = byteslice! ( @line , 0 , @byte_pointer )
2546
2547
@byte_pointer = 0
@@ -2549,8 +2550,7 @@ def finish
2549
2550
@cursor = 0
2550
2551
end
2551
2552
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
2554
2554
2555
2555
private def em_delete ( key )
2556
2556
if ( not @is_multiline and @line . empty? ) or ( @is_multiline and @line . empty? and @buffer_of_lines . size == 1 )
Original file line number Diff line number Diff line change @@ -1426,4 +1426,32 @@ def test_ed_delete_next_char_at_eol
1426
1426
assert_cursor ( 4 )
1427
1427
assert_cursor_max ( 4 )
1428
1428
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
1429
1457
end
You can’t perform that action at this time.
0 commit comments