Skip to content

Commit

Permalink
Fixing indent on initial grouping failure
Browse files Browse the repository at this point in the history
When grouping fails initially margin is not retained,
causing next indent block ending to set invalid (and eventually negative)
values.
  • Loading branch information
vandric-silverfin authored and radanskoric committed Jul 20, 2021
1 parent 1de7832 commit 0649c53
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/prawn/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ def mask(*fields) # :nodoc:
# the current page or column.
#
def group(second_attempt=false)
starting_margin_box = @bounding_box
@bounding_box = SimpleDelegator.new(@bounding_box)

@group_level ||= 0
Expand All @@ -548,11 +549,13 @@ def @bounding_box.move_past_bottom

unless success
if second_attempt
@margin_box = starting_margin_box
go_to_page(starting_page)
state.page.stack.stack = previous_graphic_state
move_cursor_to(starting_cursor)
yield
elsif @group_level > 0
@margin_box = starting_margin_box
go_to_page(starting_page)
state.page.stack.stack = previous_graphic_state
move_cursor_to(starting_cursor)
Expand All @@ -564,6 +567,7 @@ def @bounding_box.move_past_bottom
if starting_y != @bounding_box.absolute_top || @bounding_box.is_a?(Prawn::Document::ColumnBox)
@bounding_box.move_past_bottom
else
@margin_box = starting_margin_box
go_to_page(starting_page)
state.page.stack.stack = previous_graphic_state
move_cursor_to(starting_cursor)
Expand Down

0 comments on commit 0649c53

Please sign in to comment.