Skip to content
Closed
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
20 changes: 5 additions & 15 deletions Sources/GhosttyTerminalView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6727,7 +6727,6 @@ class GhosttyNSView: NSView, NSUserInterfaceValidations {
var interpretMs: Double = 0
var syncPreeditMs: Double = 0
var ghosttySendMs: Double = 0
var refreshMs: Double = 0
defer {
let totalMs = (ProcessInfo.processInfo.systemUptime - phaseTotalStart) * 1000.0
CmuxTypingTiming.logBreakdown(
Expand All @@ -6742,7 +6741,6 @@ class GhosttyNSView: NSView, NSUserInterfaceValidations {
("interpretMs", interpretMs),
("syncPreeditMs", syncPreeditMs),
("ghosttySendMs", ghosttySendMs),
("refreshMs", refreshMs),
],
extra: "marked=\(hasMarkedText() ? 1 : 0)"
)
Expand Down Expand Up @@ -6992,15 +6990,13 @@ class GhosttyNSView: NSView, NSUserInterfaceValidations {

// Use accumulated text from insertText (for IME), or compute text for key
let accumulatedText = keyTextAccumulator ?? []
var shouldRefreshAfterTextInput = false
if !accumulatedText.isEmpty {
// Accumulated text comes from insertText (IME composition result).
// These never have "composing" set to true because these are the
// result of a composition.
keyEvent.composing = false
for text in accumulatedText {
if shouldSendText(text) {
shouldRefreshAfterTextInput = true
#if DEBUG
let sendTimingStart = CmuxTypingTiming.start()
let ghosttySendStart = ProcessInfo.processInfo.systemUptime
Expand Down Expand Up @@ -7079,7 +7075,6 @@ class GhosttyNSView: NSView, NSUserInterfaceValidations {
if shouldSendText(text),
!suppressShiftSpaceFallbackText,
!suppressComposingFallbackText {
shouldRefreshAfterTextInput = true
#if DEBUG
let sendTimingStart = CmuxTypingTiming.start()
let ghosttySendStart = ProcessInfo.processInfo.systemUptime
Expand Down Expand Up @@ -7141,17 +7136,12 @@ class GhosttyNSView: NSView, NSUserInterfaceValidations {
}
}

if shouldRefreshAfterTextInput {
#if DEBUG
let refreshStart = ProcessInfo.processInfo.systemUptime
#endif
terminalSurface?.forceRefresh(reason: "keyDown.textInput")
#if DEBUG
refreshMs = (ProcessInfo.processInfo.systemUptime - refreshStart) * 1000.0
#endif
}

// Rendering is driven by Ghostty's wakeups/renderer.
// Avoid synchronous forceRefresh in the text-input hot path: during key
// repeat it runs on the main thread and can starve the coalesced Ghostty
// tick/wakeup work, which makes the terminal appear to freeze and then
// catch up in bursts. Geometry/focus recovery paths trigger explicit
// refreshes when needed.
}

@discardableResult
Expand Down