summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/reline/line_editor.rb3
-rwxr-xr-xtest/reline/yamatanooroti/multiline_repl22
-rw-r--r--test/reline/yamatanooroti/test_rendering.rb15
3 files changed, 39 insertions, 1 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index f6facc9da8..50bd22b424 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -858,7 +858,8 @@ class Reline::LineEditor
s = ' ' * width
else
s = Reline::Unicode.take_range(visual_lines[start + i], old_dialog.column + dialog.width, width)
- s = padding_space_with_escape_sequences(s, dialog.width)
+ rerender_width = old_dialog.width - dialog.width
+ s = padding_space_with_escape_sequences(s, rerender_width)
end
Reline::IOGate.move_cursor_column(dialog.column + dialog.width)
@output.write "\e[0m#{s}\e[0m"
diff --git a/test/reline/yamatanooroti/multiline_repl b/test/reline/yamatanooroti/multiline_repl
index da886b8f06..1f2a023724 100755
--- a/test/reline/yamatanooroti/multiline_repl
+++ b/test/reline/yamatanooroti/multiline_repl
@@ -137,6 +137,28 @@ opt.on('--autocomplete-super-long') {
2000.times.map{ s = "Str_#{c}"; c.succ!; s }.select{ |c| c.start_with?(target) }
}
}
+
+opt.on('--autocomplete-width-long') {
+ Reline.autocompletion = true
+ Reline.completion_proc = lambda { |target, preposing = nil, postposing = nil|
+ %w{
+ remove_instance_variable
+ respond_to?
+ ruby2_keywords
+ rand
+ readline
+ readlines
+ require
+ require_relative
+ raise
+ respond_to_missing?
+ redo
+ rescue
+ retry
+ return
+ }.select{ |c| c.start_with?(target) }
+ }
+}
opt.parse!(ARGV)
begin
diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb
index e1dde83589..f68b614327 100644
--- a/test/reline/yamatanooroti/test_rendering.rb
+++ b/test/reline/yamatanooroti/test_rendering.rb
@@ -1172,6 +1172,21 @@ begin
EOC
end
+ def test_autocomplete_old_dialog_width_greater_than_dialog_width
+ start_terminal(40, 40, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete-width-long}, startup_message: 'Multiline REPL.')
+ write("0+ \n12345678901234")
+ write("\C-p")
+ write("r")
+ write("a")
+ close
+ assert_screen(<<~'EOC')
+ Multiline REPL.
+ prompt> 0+ ra
+ prompt> 123rand 901234
+ raise
+ EOC
+ end
+
def write_inputrc(content)
File.open(@inputrc_file, 'w') do |f|
f.write content