Skip to content

Commit

Permalink
Fix completion with multiline (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng authored Mar 4, 2023
1 parent 51b0297 commit d76c482
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1371,8 +1371,8 @@ def editing_mode
@completion_state = CompletionState::MENU
end
if not just_show_list and target < completed
@line = preposing + completed + completion_append_character.to_s + postposing
line_to_pointer = preposing + completed + completion_append_character.to_s
@line = (preposing + completed + completion_append_character.to_s + postposing).split("\n")[@line_index] || String.new(encoding: @encoding)
line_to_pointer = (preposing + completed + completion_append_character.to_s).split("\n").last || String.new(encoding: @encoding)
@cursor_max = calculate_width(@line)
@cursor = calculate_width(line_to_pointer)
@byte_pointer = line_to_pointer.bytesize
Expand Down
12 changes: 12 additions & 0 deletions test/reline/yamatanooroti/test_rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,18 @@ def test_em_set_mark_and_em_exchange_mark
EOC
end

def test_multiline_completion
start_terminal(10, 50, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --complete}, startup_message: 'Multiline REPL.')
write("def hoge\n St\n St\C-p\t")
close
assert_screen(<<~'EOC')
Multiline REPL.
prompt> def hoge
prompt> String
prompt> St
EOC
end

def test_completion_journey_2nd_line
write_inputrc <<~LINES
set editing-mode vi
Expand Down

0 comments on commit d76c482

Please sign in to comment.