Skip to content
Open
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
19 changes: 16 additions & 3 deletions list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ func (f FilterState) String() string {
}[f]
}

// The location to render the status message
type StatusMessageLocation int

const (
InTitle StatusMessageLocation = iota
InStatusBar
)

// Model contains the state of this component.
type Model struct {
showTitle bool
Expand Down Expand Up @@ -189,8 +197,9 @@ type Model struct {
// 1 second.
StatusMessageLifetime time.Duration

statusMessage string
statusMessageTimer *time.Timer
statusMessage string
StatusMessageLocation StatusMessageLocation
statusMessageTimer *time.Timer

// The master set of items we're working with.
items []Item
Expand Down Expand Up @@ -1118,7 +1127,7 @@ func (m Model) titleView() string {
view += m.Styles.Title.Render(m.Title)

// Status message
if m.filterState != Filtering {
if m.filterState != Filtering && m.StatusMessageLocation == InTitle {
view += " " + m.statusMessage
view = ansi.Truncate(view, m.width-spinnerWidth, ellipsis)
}
Expand Down Expand Up @@ -1183,6 +1192,10 @@ func (m Model) statusView() string {
status += m.Styles.DividerDot.String()
status += m.Styles.StatusBarFilterCount.Render(fmt.Sprintf("%d filtered", numFiltered))
}
if m.StatusMessageLocation == InStatusBar && m.statusMessage != "" {
status += m.Styles.DividerDot.String()
status += m.statusMessage
}

return m.Styles.StatusBar.Render(status)
}
Expand Down