From 696ae5c467cf5e8da7d3f5f5a5356f26210e1117 Mon Sep 17 00:00:00 2001 From: Jonathan Daugherty Date: Thu, 21 Nov 2024 15:27:50 -0800 Subject: [PATCH] renderFinal: reset render-specific state in between renderings to avoid preservation of stale state (extents, etc) across renderings --- src/Brick/Widgets/Internal.hs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Brick/Widgets/Internal.hs b/src/Brick/Widgets/Internal.hs index c774b17..fd7075b 100644 --- a/src/Brick/Widgets/Internal.hs +++ b/src/Brick/Widgets/Internal.hs @@ -8,7 +8,7 @@ module Brick.Widgets.Internal ) where -import Lens.Micro ((^.), (&), (%~)) +import Lens.Micro ((^.), (&), (%~), (.~)) import Lens.Micro.Mtl ((%=)) import Control.Monad import Control.Monad.State.Strict @@ -35,7 +35,14 @@ renderFinal :: (Ord n) renderFinal aMap layerRenders (w, h) chooseCursor rs = (newRS, picWithBg, theCursor, concat layerExtents) where - (layerResults, !newRS) = flip runState rs $ sequence $ + -- Reset various fields from the last rendering state so they + -- don't accumulate or affect this rendering. + resetRs = rs & reportedExtentsL .~ mempty + & observedNamesL .~ mempty + & clickableNamesL .~ mempty + & requestedVisibleNames_L .~ mempty + + (layerResults, !newRS) = flip runState resetRs $ sequence $ (\p -> runReaderT p ctx) <$> (\layerWidget -> do result <- render $ cropToContext layerWidget