Skip to content

Commit 7ef59eb

Browse files
committed
Fixing muliselect
1 parent 62d05bc commit 7ef59eb

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

internal/tui/keys.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var DefaultKeys = Keys{
2222
Tab: key.NewBinding(key.WithKeys("tab"), key.WithHelp("tab", "next field")),
2323
ShiftTab: key.NewBinding(key.WithKeys("shift+tab"), key.WithHelp("shift+tab", "prev field")),
2424
Enter: key.NewBinding(key.WithKeys("enter"), key.WithHelp("enter", "confirm")),
25-
Space: key.NewBinding(key.WithKeys(" "), key.WithHelp("space", "toggle")),
25+
Space: key.NewBinding(key.WithKeys(" ", "space"), key.WithHelp("space", "toggle")),
2626
Esc: key.NewBinding(key.WithKeys("esc"), key.WithHelp("esc", "back")),
2727
Quit: key.NewBinding(key.WithKeys("ctrl+c"), key.WithHelp("ctrl+c", "quit")),
2828
}

internal/tui/multiselectfield.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ func (f *MultiSelectField) Update(msg tea.Msg) (Field, tea.Cmd) {
141141
if f.cursor < len(f.opts)-1 {
142142
f.cursor++
143143
}
144-
case " ":
144+
case " ", "space":
145+
// bubbletea v2 may deliver the spacebar as the rune " " or as the
146+
// named key "space" depending on terminal/platform. Handle both.
145147
if !f.readOnly {
146148
f.selected[f.cursor] = !f.selected[f.cursor]
147149
f.syncPtr()

internal/tui/textfield.go

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,21 +104,35 @@ func (f *TextField) View(focused bool, width int) string {
104104
}
105105
}
106106

107-
// Input box
107+
// Input box.
108+
//
109+
// Width(inputWidth+4): lipgloss v2 uses a border-box model where Width
110+
// includes the border (2 chars) but NOT padding. With Padding(0,1) that
111+
// consumes another 2 chars, leaving exactly inputWidth for the text area —
112+
// matching the SetWidth(inputWidth) call above. Using inputWidth+2 (v1
113+
// assumption) left only inputWidth-2 for wrapping, causing the textinput
114+
// content to overflow and produce a spurious second line inside the box.
115+
//
116+
// Indent: lipgloss MarginLeft in v2 does not reliably distribute the margin
117+
// to every line of a multi-line rendered block. We split on \n and prepend
118+
// " " to each line manually so the top-border, content, and bottom-border
119+
// all shift left by the same 2 columns.
108120
borderColor := ColorDim
109121
if focused {
110122
borderColor = ColorFocus
111123
}
112-
// MarginLeft applies to every line of the rendered block, unlike a manual
113-
// " " string prefix which only indents the first line.
124+
tiView := f.ti.View()
114125
box := lipgloss.NewStyle().
115126
Border(lipgloss.RoundedBorder()).
116127
BorderForeground(borderColor).
117128
Padding(0, 1).
118-
MarginLeft(2).
119-
Render(f.ti.View())
120-
sb.WriteString(box)
121-
sb.WriteByte('\n')
129+
Width(inputWidth).
130+
Render(tiView)
131+
for _, line := range strings.Split(box, "\n") {
132+
sb.WriteString(" ")
133+
sb.WriteString(line)
134+
sb.WriteByte('\n')
135+
}
122136

123137
// Inline validation error
124138
if f.errMsg != "" {

0 commit comments

Comments
 (0)