diff options
| -rw-r--r-- | lib/reline/line_editor.rb | 4 | ||||
| -rw-r--r-- | test/reline/yamatanooroti/test_rendering.rb | 13 |
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 9442bdf5cc..2a1d4b4382 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -1295,8 +1295,10 @@ class Reline::LineEditor end end completed = @completion_journey_data.list[@completion_journey_data.pointer] - @line = (@completion_journey_data.preposing + completed + @completion_journey_data.postposing).split("\n")[@line_index] + new_line = (@completion_journey_data.preposing + completed + @completion_journey_data.postposing).split("\n")[@line_index] + @line = new_line.nil? ? String.new(encoding: @encoding) : new_line line_to_pointer = (@completion_journey_data.preposing + completed).split("\n").last + line_to_pointer = String.new(encoding: @encoding) if line_to_pointer.nil? @cursor_max = calculate_width(@line) @cursor = calculate_width(line_to_pointer) @byte_pointer = line_to_pointer.bytesize diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb index 0ea5b1a25d..7a73f07d5d 100644 --- a/test/reline/yamatanooroti/test_rendering.rb +++ b/test/reline/yamatanooroti/test_rendering.rb @@ -823,6 +823,19 @@ begin EOC end + def test_completion_journey_with_empty_line + write_inputrc <<~LINES + set editing-mode vi + LINES + start_terminal(10, 50, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --complete}, startup_message: 'Multiline REPL.') + write("\C-n\C-p") + close + assert_screen(<<~'EOC') + Multiline REPL. + prompt> + EOC + end + def write_inputrc(content) File.open(@inputrc_file, 'w') do |f| f.write content |
