Skip to content

Commit

Permalink
renderFinal: reset render-specific state in between renderings to avo…
Browse files Browse the repository at this point in the history
…id preservation of stale state (extents, etc) across renderings
  • Loading branch information
jtdaugherty committed Nov 21, 2024
1 parent aeeee31 commit 696ae5c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Brick/Widgets/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 696ae5c

Please sign in to comment.