Skip to content

Commit

Permalink
Merge pull request #388 from ima1zumi/fix-calc-padding-width
Browse files Browse the repository at this point in the history
  • Loading branch information
gotoken authored Nov 21, 2021
2 parents a045668 + c581c31 commit 3cfd620
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,8 @@ def add_dialog_proc(name, p, context = nil)
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"
Expand Down
22 changes: 22 additions & 0 deletions test/reline/yamatanooroti/multiline_repl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions test/reline/yamatanooroti/test_rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,21 @@ def test_rerender_argument_prompt_after_pasting
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
Expand Down

0 comments on commit 3cfd620

Please sign in to comment.