Skip to content

Commit 4e5c43a

Browse files
authored
Fix broken TUI styling (#1023)
lipgloss v0.11.0 made it so that all the `Style` methods no longer mutate the style, which I was relying on.
1 parent 21cdb29 commit 4e5c43a

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

cmd/osv-scanner/fix/model.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -94,23 +94,23 @@ func (m *model) setTermSize(w, h int) {
9494
// resize the views to the calculated dimensions
9595
m.mainViewWidth = viewWidth
9696
m.mainViewHeight = viewHeight
97-
m.mainViewStyle.Width(paddedWidth).Height(paddedHeight)
97+
m.mainViewStyle = m.mainViewStyle.Width(paddedWidth).Height(paddedHeight)
9898

9999
m.infoViewWidth = viewWidth
100100
m.infoViewHeight = viewHeight
101-
m.infoViewStyle.Width(paddedWidth).Height(paddedHeight)
101+
m.infoViewStyle = m.infoViewStyle.Width(paddedWidth).Height(paddedHeight)
102102

103103
m.st.Resize(m.mainViewWidth, m.mainViewHeight)
104104
m.st.ResizeInfo(m.infoViewWidth, m.infoViewHeight)
105105
}
106106

107107
func (m *model) getBorderStyles() (lipgloss.Style, lipgloss.Style) {
108108
if m.st.IsInfoFocused() {
109-
m.infoViewStyle.UnsetBorderForeground()
110-
m.mainViewStyle.BorderForeground(tui.ColorDisabled)
109+
m.infoViewStyle = m.infoViewStyle.UnsetBorderForeground()
110+
m.mainViewStyle = m.mainViewStyle.BorderForeground(tui.ColorDisabled)
111111
} else {
112-
m.infoViewStyle.BorderForeground(tui.ColorDisabled)
113-
m.mainViewStyle.UnsetBorderForeground()
112+
m.infoViewStyle = m.infoViewStyle.BorderForeground(tui.ColorDisabled)
113+
m.mainViewStyle = m.mainViewStyle.UnsetBorderForeground()
114114
}
115115

116116
return m.mainViewStyle, m.infoViewStyle

internal/tui/in-place-info.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ func NewInPlaceInfo(res remediation.InPlaceResult) *inPlaceInfo {
7777
}
7878

7979
st := table.DefaultStyles()
80-
st.Header.Bold(false).BorderStyle(lipgloss.NormalBorder()).BorderBottom(true)
81-
st.Selected.Foreground(ColorPrimary)
80+
st.Header = st.Header.Bold(false).BorderStyle(lipgloss.NormalBorder()).BorderBottom(true)
81+
st.Selected = st.Selected.Foreground(ColorPrimary)
8282

8383
info.Model = table.New(
8484
table.WithColumns(cols),

internal/tui/vuln-list.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (v *vulnList) preambleHeight() int {
9494
func (v *vulnList) Resize(w, h int) {
9595
v.SetWidth(w)
9696
v.SetHeight(h - v.preambleHeight())
97-
v.Styles.TitleBar.Width(w)
97+
v.Styles.TitleBar = v.Styles.TitleBar.Width(w)
9898
if v.currVulnInfo != nil {
9999
v.currVulnInfo.Resize(w, h)
100100
}
@@ -176,7 +176,7 @@ func (d vulnListItemDelegate) Render(w io.Writer, m list.Model, index int, listI
176176
idStyle := lipgloss.NewStyle().Width(d.idWidth).Align(lipgloss.Left)
177177
if index == m.Index() {
178178
cursor = SelectedTextStyle.Render(">")
179-
idStyle.Inherit(SelectedTextStyle)
179+
idStyle = idStyle.Inherit(SelectedTextStyle)
180180
}
181181
id := idStyle.Render(vuln.Vulnerability.ID)
182182
severity := RenderSeverityShort(vuln.Vulnerability.Severity)

0 commit comments

Comments
 (0)