From 653c6a56fc15ce076e97e85240205e5670c08342 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Thu, 10 Jul 2025 13:15:29 -0400 Subject: [PATCH] fix(tui): permission: make sure the fetch content has the correct background color --- .../dialogs/permissions/permissions.go | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/internal/tui/components/dialogs/permissions/permissions.go b/internal/tui/components/dialogs/permissions/permissions.go index e7f6dd517b1504e2f938c9310e95b8a7086cbbf0..0e26cc063ad826c2306428b0f12cbc29abc02199 100644 --- a/internal/tui/components/dialogs/permissions/permissions.go +++ b/internal/tui/components/dialogs/permissions/permissions.go @@ -16,6 +16,7 @@ import ( "github.com/charmbracelet/crush/internal/tui/styles" "github.com/charmbracelet/crush/internal/tui/util" "github.com/charmbracelet/lipgloss/v2" + uv "github.com/charmbracelet/ultraviolet" "github.com/charmbracelet/x/ansi" ) @@ -395,7 +396,22 @@ func (p *permissionDialogCmp) generateFetchContent() string { Width(p.contentViewPort.Width()). Render(renderedContent) - return finalContent + // We render the content into a buffer with the size of the viewport + // width and height of the content. Then we make sure each cell has the + // appropriate background color. + ss := uv.NewStyledString(finalContent) + scr := uv.NewScreenBuffer(p.contentViewPort.Width(), lipgloss.Height(finalContent)) + ss.Draw(scr, scr.Bounds()) + for y := 0; y < scr.Height(); y++ { + for x := 0; x < scr.Width(); x++ { + cell := scr.CellAt(x, y) + if cell != nil { + cell.Style.Bg = t.BgSubtle + } + } + } + + return scr.Render() } return "" } @@ -452,8 +468,8 @@ func (p *permissionDialogCmp) render() string { if p.supportsDiffView() { contentHelp = help.New().View(p.keyMap) } - // Calculate content height dynamically based on window size + // Calculate content height dynamically based on window size strs := []string{ title, "",