зеркало из https://github.com/github/ruby.git
[ruby/reline] Fix a crash when completing empty line
https://github.com/ruby/reline/commit/8226ae7e57
This commit is contained in:
Родитель
5f23003cc2
Коммит
4852d87a81
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче