Skip to content

Commit 07a73ba

Browse files
committed
Move the cursor correctly when deleting at eol
This fixes #246.
1 parent 22c6db7 commit 07a73ba

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/reline/line_editor.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2395,6 +2395,9 @@ def finish
23952395
width = Reline::Unicode.get_mbchar_width(mbchar)
23962396
@cursor_max -= width
23972397
if @cursor > 0 and @cursor >= @cursor_max
2398+
byte_size = Reline::Unicode.get_prev_mbchar_size(@line, @byte_pointer)
2399+
mbchar = @line.byteslice(@byte_pointer - byte_size, byte_size)
2400+
width = Reline::Unicode.get_mbchar_width(mbchar)
23982401
@byte_pointer -= byte_size
23992402
@cursor -= width
24002403
end

test/reline/test_key_actor_vi.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,4 +1434,22 @@ def test_pasting_fullwidth
14341434
assert_cursor(4)
14351435
assert_cursor_max(4)
14361436
end
1437+
1438+
def test_ed_delete_next_char_at_eol
1439+
input_keys('"あ"')
1440+
assert_line('"あ"')
1441+
assert_byte_pointer_size('"あ"')
1442+
assert_cursor(4)
1443+
assert_cursor_max(4)
1444+
input_keys("\C-[")
1445+
assert_line('"あ"')
1446+
assert_byte_pointer_size('"あ')
1447+
assert_cursor(3)
1448+
assert_cursor_max(4)
1449+
input_keys('xa"')
1450+
assert_line('"あ"')
1451+
assert_byte_pointer_size('"あ"')
1452+
assert_cursor(4)
1453+
assert_cursor_max(4)
1454+
end
14371455
end

0 commit comments

Comments
 (0)