Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Sources/GhosttyTerminalView+Keyboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,11 @@ extension GhosttyNSView {
#if DEBUG
let refreshStart = ProcessInfo.processInfo.systemUptime
#endif
terminalSurface?.forceRefresh(reason: "keyDown.textInput")
// PERF (#183): deliberately not forceRefresh. Typing changes grid
// contents, never the surface's geometry or display, so the display-id
// reassert and forceRefreshSurface() that forceRefresh does are pure
// cost here. forceRefresh stays for the topology changes it exists for.
terminalSurface?.requestRedrawAfterInput()
#if DEBUG
refreshMs = (ProcessInfo.processInfo.systemUptime - refreshStart) * 1000.0
ProgramaDurationSamples.shared.record("keyDown.textInputRefresh", milliseconds: refreshMs)
Expand Down
23 changes: 23 additions & 0 deletions Sources/TerminalSurface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,29 @@ final class TerminalSurface: Identifiable, ObservableObject {
return true
}

/// Ask Ghostty to redraw after committed text input, without the geometry
/// reconciliation `forceRefresh` does.
///
/// PERF (#183): this runs after every printable keystroke. `forceRefresh`
/// additionally reasserts the display id and calls `forceRefreshSurface()`,
/// which exist for *topology* changes -- split close/reparent, and the
/// stuck-vsync state after wake-from-sleep -- none of which a character can
/// cause. Typing changes the grid contents, not the surface's size or which
/// display it lives on.
///
/// The early-out conditions are deliberately identical to `forceRefresh`'s,
/// so *when* a redraw happens is unchanged; only the work done differs.
func requestRedrawAfterInput() {
guard let view = attachedView,
view.window != nil,
view.bounds.width > 0,
view.bounds.height > 0 else {
return
}
guard let surface = self.surface else { return }
ghostty_surface_refresh(surface)
}

/// Force a full size recalculation and surface redraw.
func forceRefresh(reason: String = "unspecified") {
// PERF (#183): this diagnostic string is consumed only by the DEBUG-only `dlog` below,
Expand Down
Loading