From 0649c5339ef2155c32950d1576d03268e6f9077f Mon Sep 17 00:00:00 2001 From: Vladimir Andric Date: Fri, 16 Jul 2021 03:09:15 +0200 Subject: [PATCH] Fixing indent on initial grouping failure When grouping fails initially margin is not retained, causing next indent block ending to set invalid (and eventually negative) values. --- lib/prawn/document.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/prawn/document.rb b/lib/prawn/document.rb index 8a33caaba..034e9a9c6 100644 --- a/lib/prawn/document.rb +++ b/lib/prawn/document.rb @@ -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 @@ -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) @@ -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)