Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions cmd/status/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ type model struct {
catHidden bool // true = hidden, false = visible
}

// padViewToHeight ensures the rendered frame always overwrites the full
// terminal region by padding with empty lines up to the current height.
func padViewToHeight(view string, height int) string {
if height <= 0 {
return view
}

contentHeight := lipgloss.Height(view)
if contentHeight >= height {
return view
}

return view + strings.Repeat("\n", height-contentHeight)
}

// getConfigPath returns the path to the status preferences file.
func getConfigPath() string {
home, err := os.UserHomeDir()
Expand Down Expand Up @@ -194,17 +209,7 @@ func (m model) View() string {
}
parts = append(parts, cardContent)
output := lipgloss.JoinVertical(lipgloss.Left, parts...)

// Pad output to exactly fill the terminal height so every frame fully
// overwrites the alt screen buffer, preventing ghost lines on resize.
if m.height > 0 {
contentHeight := lipgloss.Height(output)
if contentHeight < m.height {
output += strings.Repeat("\n", m.height-contentHeight)
}
}

return output
return padViewToHeight(output, m.height)
}

func (m model) collectCmd() tea.Cmd {
Expand Down
7 changes: 5 additions & 2 deletions tests/core_common.bats
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ EOF
}

@test "should_protect_path protects Mole runtime logs" {
result="$(HOME="$HOME" bash --noprofile --norc -c "source '$PROJECT_ROOT/lib/core/common.sh'; should_protect_path '$HOME/Library/Logs/mole/operations.log' && echo protected || echo not-protected")"
result="$(
HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc -c \
'source "$PROJECT_ROOT/lib/core/common.sh"; should_protect_path "$HOME/Library/Logs/mole/operations.log" && echo protected || echo not-protected'
)"
[ "$result" = "protected" ]
}

Expand Down Expand Up @@ -241,7 +244,7 @@ EOF

PATH="$fake_bin:$PATH" PROJECT_ROOT="$PROJECT_ROOT" HOME="$HOME" \
/usr/bin/script -q /dev/null /bin/bash --noprofile --norc -c \
'source "$PROJECT_ROOT/lib/core/common.sh"; start_inline_spinner "Testing..."; /bin/sleep 0.15; stop_inline_spinner' \
"source \"\$PROJECT_ROOT/lib/core/common.sh\"; start_inline_spinner \"Testing...\"; /bin/sleep 0.15; stop_inline_spinner" \
> /dev/null 2>&1

[ ! -f "$marker" ]
Expand Down