Skip to content

Commit

Permalink
Add better "no files" message
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Nov 15, 2022
1 parent 2ee01a8 commit 352455d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var (
cursor = lipgloss.NewStyle().Background(lipgloss.Color("#825DF2")).Foreground(lipgloss.Color("#FFFFFF"))
bar = lipgloss.NewStyle().Background(lipgloss.Color("#5C5C5C")).Foreground(lipgloss.Color("#FFFFFF"))
search = lipgloss.NewStyle().Background(lipgloss.Color("#499F1C")).Foreground(lipgloss.Color("#FFFFFF"))
noFiles = lipgloss.NewStyle().Border(lipgloss.RoundedBorder())
)

type keymap struct {
Expand Down Expand Up @@ -358,9 +359,6 @@ func (m *model) moveBottom() {
}

func (m *model) View() string {
if len(m.files) == 0 {
return "No files"
}

// If it's possible to fit all files in one column on a third of the screen,
// just use one column. Otherwise, let's squeeze listing in half of screen.
Expand Down Expand Up @@ -462,7 +460,12 @@ start:
location = location[barLen-m.width:]
}
bar := bar.Render(location) + search.Render(filter)
return bar + "\n" + Join(output, "\n")

empty := ""
if len(m.files) == 0 {
empty = noFiles.Render(" No files ")
}
return bar + "\n" + Join(output, "\n") + empty
}

func (m *model) list() {
Expand Down

0 comments on commit 352455d

Please sign in to comment.