7ed1994836790f4f5e43163ed3a539b18d80480f

Author
Ayman Bagabas <ayman.bagabas@gmail.com>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

fix(ui): ensure the code component width accounts for the horizontal
frame size

Diff

 1diff --git a/pkg/ui/components/code/code.go b/pkg/ui/components/code/code.go
 2index 50e56f4aff0112ac095c5788227b3c9112bfe9f0..416cd85d0a0066396f506f595592e74524b6c76b 100644
 3--- a/pkg/ui/components/code/code.go
 4+++ b/pkg/ui/components/code/code.go
 5@@ -77,7 +77,11 @@ func (r *Code) SetSideNote(s string) tea.Cmd {
 6 
 7 // Init implements tea.Model.
 8 func (r *Code) Init() tea.Cmd {
 9-	w := r.common.Width
10+	// XXX: We probably won't need the GetHorizontalFrameSize margin
11+	// subtraction if we get the new viewport soft wrapping to play nicely with
12+	// Glamour. This also introduces a bug where when it soft wraps, the
13+	// viewport scrolls left/right for 2 columns on each side of the screen.
14+	w := r.common.Width - r.common.Styles.App.GetHorizontalFrameSize()
15 	content := r.content
16 	if content == "" {
17 		r.Viewport.Model.SetContent(r.NoContentStyle.String())