diff options
author | ima1zumi <[email protected]> | 2021-11-17 00:58:43 +0900 |
---|---|---|
committer | git <[email protected]> | 2021-11-21 13:56:26 +0900 |
commit | f5829e293583aa6ba6a1f1314ee22881d58a5f96 (patch) | |
tree | f8ec61d0bb33bc7eed7a58afc133df139e14e560 /lib/reline/line_editor.rb | |
parent | feda058531c0bdd5b673180accb4407dcc798c79 (diff) |
[ruby/reline] Correct padding space calculation
fix https://github.com/ruby/irb/issues/308
This bug occurred when `dialog.width - calculate_width(s, true)` was negative.
When `dialog.width` is shorter than `old_dialog.width`, it calculates how much padding it has to do. However, there are cases where `s` is longer than `dialog.width`, as in the issue. In that case, `padding_space_with_escape_sequences` will crash.
Here, `old_dialog.width` is longer than `dialog.width`, so I changed the padding width to `old_dialog.width - dialog.width`.
https://github.com/ruby/reline/commit/c581c31e0f
Diffstat (limited to 'lib/reline/line_editor.rb')
-rw-r--r-- | lib/reline/line_editor.rb | 3 |
1 files changed, 2 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" |