Skip to content

Commit

Permalink
cropRightBy, cropBottomBy: properly set context before cropping result
Browse files Browse the repository at this point in the history
  • Loading branch information
jtdaugherty committed Feb 11, 2025
1 parent 12c0d5c commit 72b2c61
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Brick/Widgets/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,8 @@ cropRightBy cols p =
result <- render p
let amt = V.imageWidth (result^.imageL) - cols
cropped img = if amt < 0 then V.emptyImage else V.cropRight amt img
cropResultToContext $ result & imageL %~ cropped
withReaderT (availWidthL .~ amt) $
cropResultToContext $ result & imageL %~ cropped

-- | Crop the specified widget to the specified size from the right.
-- Defers to the cropped widget for growth policy.
Expand Down Expand Up @@ -1186,7 +1187,8 @@ cropBottomBy rows p =
result <- render p
let amt = V.imageHeight (result^.imageL) - rows
cropped img = if amt < 0 then V.emptyImage else V.cropBottom amt img
cropResultToContext $ result & imageL %~ cropped
withReaderT (availHeightL .~ amt) $
cropResultToContext $ result & imageL %~ cropped

-- | Crop the specified widget to the specified size from the bottom.
-- Defers to the cropped widget for growth policy.
Expand Down

0 comments on commit 72b2c61

Please sign in to comment.