macOS: move search result counter inside text field

Move the search result counter (e.g. "1/30") inside the search text
field using an overlay, preventing layout shift when results appear.

This PR was authored with Claude Code.
pull/9713/head
avarayr 2025-11-26 13:04:05 -05:00
parent 71a2dad929
commit f5b923573d
No known key found for this signature in database
1 changed files with 18 additions and 14 deletions

View File

@ -409,11 +409,27 @@ extension Ghostty {
TextField("Search", text: $searchState.needle)
.textFieldStyle(.plain)
.frame(width: 180)
.padding(.horizontal, 8)
.padding(.leading, 8)
.padding(.trailing, 50)
.padding(.vertical, 6)
.background(Color.primary.opacity(0.1))
.cornerRadius(6)
.focused($isSearchFieldFocused)
.overlay(alignment: .trailing) {
if let selected = searchState.selected {
Text("\(selected + 1)/\(searchState.total, default: "?")")
.font(.caption)
.foregroundColor(.secondary)
.monospacedDigit()
.padding(.trailing, 8)
} else if let total = searchState.total {
Text("-/\(total)")
.font(.caption)
.foregroundColor(.secondary)
.monospacedDigit()
.padding(.trailing, 8)
}
}
#if canImport(AppKit)
.onExitCommand {
Ghostty.moveFocus(to: surfaceView)
@ -428,18 +444,6 @@ extension Ghostty {
return .handled
}
if let selected = searchState.selected {
Text("\(selected + 1)/\(searchState.total, default: "?")")
.font(.caption)
.foregroundColor(.secondary)
.monospacedDigit()
} else if let total = searchState.total {
Text("-/\(total)")
.font(.caption)
.foregroundColor(.secondary)
.monospacedDigit()
}
Button(action: {
guard let surface = surfaceView.surface else { return }
let action = "navigate_search:next"