From e9f82585eed414ff090d9ef7b667d0f3c1561a01 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Thu, 8 Aug 2019 18:38:40 -0400 Subject: Don't crash when deleting at the end of the line To reproduce this bug, type one character into irb, then press the delete key on your keyboard. --- lib/reline/line_editor.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/reline/line_editor.rb') diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 4c97a6fed9..742ffedf9a 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -1712,8 +1712,8 @@ class Reline::LineEditor end private def ed_delete_next_char(key, arg: 1) - unless @line.empty? - byte_size = Reline::Unicode.get_next_mbchar_size(@line, @byte_pointer) + byte_size = Reline::Unicode.get_next_mbchar_size(@line, @byte_pointer) + unless @line.empty? || byte_size == 0 @line, mbchar = byteslice!(@line, @byte_pointer, byte_size) copy_for_vi(mbchar) width = Reline::Unicode.get_mbchar_width(mbchar) -- cgit v1.2.3