Skip to content

Commit

Permalink
Calc width including escape sequences and padding with spaces correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed Sep 1, 2021
1 parent 9b812d5 commit 21c795e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,9 @@ def add_dialog_proc(name, p, context = nil)
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
Expand Down

0 comments on commit 21c795e

Please sign in to comment.