From d2471911bb2e5335c318bdf45688039b46ea642e Mon Sep 17 00:00:00 2001 From: Jonathan Daugherty Date: Sat, 20 Nov 2021 15:04:44 -0800 Subject: [PATCH] lookupViewport: add extra notes about behavior (relevant to #349) --- src/Brick/Main.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Brick/Main.hs b/src/Brick/Main.hs index 534efa4..0816a3f 100644 --- a/src/Brick/Main.hs +++ b/src/Brick/Main.hs @@ -390,7 +390,13 @@ applyInvalidations ns cache = -- information from the most recent rendering. Returns 'Nothing' if -- no such state could be found, either because the name was invalid -- or because no rendering has occurred (e.g. in an 'appStartEvent' --- handler). +-- handler). An important consequence of this behavior is that if this +-- function is called before a viewport is rendered for the first +-- time, no state will be found because the renderer only knows about +-- viewports it has rendered in the most recent rendering. As a result, +-- if you need to make viewport transformations before they are drawn +-- for the first time, you may need to use 'viewportScroll' and its +-- associated functions without relying on this function. lookupViewport :: (Ord n) => n -> EventM n (Maybe Viewport) lookupViewport n = EventM $ asks (M.lookup n . eventViewportMap)