diff options
author | aycabta <aycabta@gmail.com> | 2021-09-01 17:53:17 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2021-09-01 18:05:25 +0900 |
commit | a669b9661eaf9623160e2f2010f24b0b9fd5f01a (patch) | |
tree | 69281a452564e7518bdfcb55f3371c54791c992e | |
parent | 3bd3adde7cd952046539ca5ecd21d1bcfa2fe568 (diff) |
[ruby/reline] Calc width including escape sequences and padding with spaces correctly
https://github.com/ruby/reline/commit/21c795e97f
-rw-r--r-- | lib/reline/line_editor.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 9ea0f0731b..9df04f14f4 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -651,7 +651,9 @@ class Reline::LineEditor bg_color = '46' end end - @output.write "\e[#{bg_color}m%-#{dialog.width}s\e[49m" % Reline::Unicode.take_range(item, 0, dialog.width) + str = Reline::Unicode.take_range(item, 0, dialog.width) + str += ' ' * (dialog.width - calculate_width(str, true)) + @output.write "\e[#{bg_color}m#{str}\e[49m" Reline::IOGate.move_cursor_column(dialog.column) move_cursor_down(1) if i < (dialog.contents.size - 1) end |