Skip to content

Commit 936e453

Browse files
committed
fix: search badge now properly clears on 'c' keypress
- Split renderSearchBar into separate input and badge functions - Added explicit empty check guard in renderSearchBadge - Version bump to v0.3.1 Fixes: Search badge showing stale query after clearing
1 parent 730583d commit 936e453

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

cmd/git-scope/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/Bharath-code/git-scope/internal/tui"
1515
)
1616

17-
const version = "0.3.0"
17+
const version = "0.3.1"
1818

1919
func usage() {
2020
fmt.Fprintf(os.Stderr, `git-scope v%s — A fast TUI to see the status of all git repositories

git-scope-test

4.87 MB
Binary file not shown.

internal/tui/view.go

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (m Model) renderDashboard() string {
7979

8080
// Header with logo on its own line
8181
logo := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("#A78BFA")).Render("git-scope")
82-
version := lipgloss.NewStyle().Foreground(lipgloss.Color("#6B7280")).Render(" v0.3.0")
82+
version := lipgloss.NewStyle().Foreground(lipgloss.Color("#6B7280")).Render(" v0.3.1")
8383
b.WriteString(logo + version)
8484
b.WriteString("\n\n")
8585

@@ -88,9 +88,13 @@ func (m Model) renderDashboard() string {
8888
b.WriteString("\n")
8989

9090
// Search bar (show when searching or has active search)
91-
if m.state == StateSearching || m.searchQuery != "" {
91+
if m.state == StateSearching {
9292
b.WriteString(m.renderSearchBar())
9393
b.WriteString("\n")
94+
} else if m.searchQuery != "" {
95+
// Show search badge only if searchQuery is actually set
96+
b.WriteString(m.renderSearchBadge())
97+
b.WriteString("\n")
9498
}
9599

96100
b.WriteString("\n")
@@ -121,13 +125,18 @@ func (m Model) renderSearchBar() string {
121125
BorderForeground(lipgloss.Color("#7C3AED")).
122126
Padding(0, 1)
123127

124-
if m.state == StateSearching {
125-
// Show active search input
126-
label := lipgloss.NewStyle().
127-
Foreground(lipgloss.Color("#7C3AED")).
128-
Bold(true).
129-
Render("🔍 Search: ")
130-
return searchStyle.Render(label + m.textInput.View())
128+
// Show active search input
129+
label := lipgloss.NewStyle().
130+
Foreground(lipgloss.Color("#7C3AED")).
131+
Bold(true).
132+
Render("🔍 Search: ")
133+
return searchStyle.Render(label + m.textInput.View())
134+
}
135+
136+
func (m Model) renderSearchBadge() string {
137+
// Guard: don't render empty badge
138+
if m.searchQuery == "" {
139+
return ""
131140
}
132141

133142
// Show current search query as badge

0 commit comments

Comments
 (0)