Skip to content

Commit

Permalink
Merge pull request #341 from aycabta/fix-reset-logic
Browse files Browse the repository at this point in the history
Fix reset logic
  • Loading branch information
aycabta authored Sep 7, 2021
2 parents 7e3eb64 + 5cea268 commit dc50b59
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -706,9 +706,10 @@ def add_dialog_proc(name, p, context = nil)
bg_color = '46'
end
end
str = padding_space_with_escape_sequences(Reline::Unicode.take_range(item, 0, dialog.width - @block_elem_width), dialog.width - @block_elem_width)
str_width = dialog.width - (dialog.scrollbar_pos.nil? ? 0 : @block_elem_width)
str = padding_space_with_escape_sequences(Reline::Unicode.take_range(item, 0, str_width), str_width)
@output.write "\e[#{bg_color}m#{str}"
if dialog.scrollbar_pos and dialog.scrollbar_pos != old_dialog.scrollbar_pos
if dialog.scrollbar_pos and (dialog.scrollbar_pos != old_dialog.scrollbar_pos or dialog.column != old_dialog.column)
@output.write "\e[37m"
if dialog.scrollbar_pos <= (i * 2) and (i * 2 + @block_elem_width) < (dialog.scrollbar_pos + bar_height)
@output.write '█'
Expand Down Expand Up @@ -810,9 +811,7 @@ def add_dialog_proc(name, p, context = nil)
end
move_cursor_up(old_dialog.vertical_offset + line_num - 1 - y_diff)
end
old_dialog_scrollbar = old_dialog.scrollbar_pos.nil? ? 0 : @block_elem_width
dialog_scrollbar = dialog.scrollbar_pos.nil? ? 0 : @block_elem_width
if (old_dialog.column + old_dialog.width - old_dialog_scrollbar) > (dialog.column + dialog.width - dialog_scrollbar)
if (old_dialog.column + old_dialog.width) > (dialog.column + dialog.width)
# rerender right
move_cursor_down(old_dialog.vertical_offset + y_diff)
width = (old_dialog.column + old_dialog.width) - (dialog.column + dialog.width)
Expand Down

0 comments on commit dc50b59

Please sign in to comment.