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
parent
71a2dad929
commit
f5b923573d
|
|
@ -409,11 +409,27 @@ extension Ghostty {
|
||||||
TextField("Search", text: $searchState.needle)
|
TextField("Search", text: $searchState.needle)
|
||||||
.textFieldStyle(.plain)
|
.textFieldStyle(.plain)
|
||||||
.frame(width: 180)
|
.frame(width: 180)
|
||||||
.padding(.horizontal, 8)
|
.padding(.leading, 8)
|
||||||
|
.padding(.trailing, 50)
|
||||||
.padding(.vertical, 6)
|
.padding(.vertical, 6)
|
||||||
.background(Color.primary.opacity(0.1))
|
.background(Color.primary.opacity(0.1))
|
||||||
.cornerRadius(6)
|
.cornerRadius(6)
|
||||||
.focused($isSearchFieldFocused)
|
.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)
|
#if canImport(AppKit)
|
||||||
.onExitCommand {
|
.onExitCommand {
|
||||||
Ghostty.moveFocus(to: surfaceView)
|
Ghostty.moveFocus(to: surfaceView)
|
||||||
|
|
@ -427,19 +443,7 @@ extension Ghostty {
|
||||||
ghostty_surface_binding_action(surface, action, UInt(action.count))
|
ghostty_surface_binding_action(surface, action, UInt(action.count))
|
||||||
return .handled
|
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: {
|
Button(action: {
|
||||||
guard let surface = surfaceView.surface else { return }
|
guard let surface = surfaceView.surface else { return }
|
||||||
let action = "navigate_search:next"
|
let action = "navigate_search:next"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue