diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-05 21:50:58 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-05 21:50:58 +0200 |
| commit | a4298701546b09fccb15ce30db7c7e3f4070525c (patch) | |
| tree | b3433014284ccd354be48efb2ce125ccaf236d7e /internal/tui/pidpicker | |
| parent | 2bd89ced830f97fd12a672fddb6978d204a014fd (diff) | |
fix(tui): stabilize full-width layout and sparkline rendering
Diffstat (limited to 'internal/tui/pidpicker')
| -rw-r--r-- | internal/tui/pidpicker/model.go | 10 | ||||
| -rw-r--r-- | internal/tui/pidpicker/model_test.go | 10 |
2 files changed, 18 insertions, 2 deletions
diff --git a/internal/tui/pidpicker/model.go b/internal/tui/pidpicker/model.go index 87c200c..cfd0c0f 100644 --- a/internal/tui/pidpicker/model.go +++ b/internal/tui/pidpicker/model.go @@ -129,7 +129,11 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case tea.WindowSizeMsg: m.width = msg.Width m.height = msg.Height - m.input.SetWidth(clamp(msg.Width-16, 10, 100)) + inputWidth := msg.Width - 16 + if inputWidth < 10 { + inputWidth = 10 + } + m.input.SetWidth(inputWidth) return m, nil case processesLoadedMsg: m.processes = msg.processes @@ -276,7 +280,9 @@ func (m Model) View() tea.View { } b.WriteString("\n") - b.WriteString(helpBarStyle.Render(renderHelp(m.keys.PickerShortHelp()))) + viewWidth, _ := common.EffectiveViewport(m.width, m.height) + helpStyle := helpBarStyle.Copy().Width(viewWidth) + b.WriteString(helpStyle.Render(renderHelp(m.keys.PickerShortHelp()))) return tea.NewView(screenStyle.Render(b.String())) } diff --git a/internal/tui/pidpicker/model_test.go b/internal/tui/pidpicker/model_test.go index c47e59b..038575b 100644 --- a/internal/tui/pidpicker/model_test.go +++ b/internal/tui/pidpicker/model_test.go @@ -152,3 +152,13 @@ func TestRenderRowsKeepsSelectionVisible(t *testing.T) { t.Fatalf("expected selected row to remain visible, got:\n%s", rows) } } + +func TestWindowSizeDoesNotCapInputWidthOnWideTerminals(t *testing.T) { + m := NewWithKeys(DefaultKeyMap()) + next, _ := m.Update(tea.WindowSizeMsg{Width: 160, Height: 40}) + updated := next.(Model) + + if got, want := updated.input.Width(), 144; got != want { + t.Fatalf("expected input width %d for 160-col terminal, got %d", want, got) + } +} |
