summaryrefslogtreecommitdiff
path: root/internal/tui
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-13 09:28:45 +0300
committerPaul Buetow <paul@buetow.org>2026-05-13 09:28:45 +0300
commitb086d3680e845a94c6662811c7f40e9592c3dec6 (patch)
tree3e0adfeff115dc516770038330b303561cf0bd64 /internal/tui
parentd41c192150391bb5da9b38b0ea84dc0f1ea65e48 (diff)
unify filter summary rendering by reusing globalfilter helpers
Export AppendStringSummary and AppendNumericSummary from globalfilter so filterstack.go can delegate to the canonical token-formatting logic instead of reimplementing fmt.Sprintf("%s~%s") and fmt.Sprintf("%sOP%s") in appendStringFilterChange / appendNumericFilterChange. Drop the now-unused fmt, strconv, and time imports from filterstack.go. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/tui')
-rw-r--r--internal/tui/filterstack.go17
1 files changed, 8 insertions, 9 deletions
diff --git a/internal/tui/filterstack.go b/internal/tui/filterstack.go
index 3aadea3..dbd26a0 100644
--- a/internal/tui/filterstack.go
+++ b/internal/tui/filterstack.go
@@ -1,10 +1,7 @@
package tui
import (
- "fmt"
- "strconv"
"strings"
- "time"
"ior/internal/globalfilter"
)
@@ -132,6 +129,9 @@ func globalFilterActionLabel(prev, next globalfilter.Filter, action string) stri
return strings.Join(parts, " ")
}
+// appendStringFilterChange appends a change token to parts for a string
+// filter field. It emits "clear name" when the filter is removed, or delegates
+// to globalfilter.AppendStringSummary for the canonical "name~pattern" format.
func appendStringFilterChange(parts []string, name string, prev, next *globalfilter.StringFilter) []string {
if sameStringFilter(prev, next) {
return parts
@@ -139,9 +139,12 @@ func appendStringFilterChange(parts []string, name string, prev, next *globalfil
if next == nil || strings.TrimSpace(next.Pattern) == "" {
return append(parts, "clear "+name)
}
- return append(parts, fmt.Sprintf("%s~%s", name, strings.TrimSpace(next.Pattern)))
+ return globalfilter.AppendStringSummary(parts, name, next)
}
+// appendNumericFilterChange appends a change token to parts for a numeric
+// filter field. It emits "clear name" when the filter is removed, or delegates
+// to globalfilter.AppendNumericSummary for the canonical "nameOPvalue" format.
func appendNumericFilterChange(parts []string, name string, prev, next *globalfilter.NumericFilter, duration bool) []string {
if sameNumericFilter(prev, next) {
return parts
@@ -149,11 +152,7 @@ func appendNumericFilterChange(parts []string, name string, prev, next *globalfi
if next == nil {
return append(parts, "clear "+name)
}
- value := strconv.FormatInt(next.Value, 10)
- if duration {
- value = time.Duration(next.Value).String()
- }
- return append(parts, fmt.Sprintf("%s%s%s", name, globalfilter.CompareOpSymbol(next.Op), value))
+ return globalfilter.AppendNumericSummary(parts, name, next, duration)
}
func sameStringFilter(a, b *globalfilter.StringFilter) bool {