Repository navigation
Fix clipboard manager paste failing during focus transitions #2435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12939,7 +12939,25 @@ private extension NSWindow { | |||||||||
| // When the terminal is focused, skip the full NSWindow.performKeyEquivalent | ||||||||||
| // (which walks the SwiftUI content view hierarchy) and dispatch Command-key | ||||||||||
| // events directly to the main menu. This avoids the broken SwiftUI focus path. | ||||||||||
| if firstResponderGhosttyView != nil, | ||||||||||
| // | ||||||||||
| // When the first responder is the window itself (focus transition after | ||||||||||
| // a clipboard-manager overlay like Raycast/Tuna dismisses), restore the | ||||||||||
| // terminal as first responder before dispatching. Without this, the main | ||||||||||
| // menu can't validate items (no responder handles paste:/copy:) and the | ||||||||||
| // original performKeyEquivalent walks the broken SwiftUI focus path. | ||||||||||
| var menuBypassGhosttyView = firstResponderGhosttyView | ||||||||||
| if menuBypassGhosttyView == nil, self.firstResponder is NSWindow { | ||||||||||
| if let terminalPanel = AppDelegate.shared?.tabManager?.selectedWorkspace?.focusedTerminalPanel, | ||||||||||
| let ghosttyNSView = Self.findGhosttyNSView(in: terminalPanel.hostedView) { | ||||||||||
| self.makeFirstResponder(ghosttyNSView) | ||||||||||
| menuBypassGhosttyView = ghosttyNSView | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Gating the assignment on the return value makes the intent explicit and avoids the spurious menu invocation:
Suggested change
You'd also need a closing |
||||||||||
| #if DEBUG | ||||||||||
| dlog(" → focus-transition recovery: restored terminal as firstResponder") | ||||||||||
| #endif | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| if menuBypassGhosttyView != nil, | ||||||||||
| shouldRouteCommandEquivalentDirectlyToMainMenu(event), | ||||||||||
| let mainMenu = NSApp.mainMenu { | ||||||||||
| let consumedByMenu = mainMenu.performKeyEquivalent(with: event) | ||||||||||
|
|
@@ -12956,9 +12974,7 @@ private extension NSWindow { | |||||||||
| ) | ||||||||||
| } | ||||||||||
| #endif | ||||||||||
| if !consumedByMenu { | ||||||||||
| // Fall through to the original performKeyEquivalent path below. | ||||||||||
| } else { | ||||||||||
| if consumedByMenu { | ||||||||||
| #if DEBUG | ||||||||||
| dlog(" → consumed by mainMenu (bypassed SwiftUI)") | ||||||||||
| #endif | ||||||||||
|
|
@@ -12973,6 +12989,18 @@ private extension NSWindow { | |||||||||
| return result | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /// Walk the subview tree downward to find the GhosttyNSView inside a hosted view. | ||||||||||
| /// Unlike `cmuxOwningGhosttyView(for:)` which walks upward through superviews, | ||||||||||
| /// this walks downward — needed when starting from the GhosttySurfaceScrollView | ||||||||||
| /// container whose surfaceView property is private. | ||||||||||
| static func findGhosttyNSView(in view: NSView) -> GhosttyNSView? { | ||||||||||
| if let ghosttyView = view as? GhosttyNSView { return ghosttyView } | ||||||||||
| for subview in view.subviews { | ||||||||||
| if let found = findGhosttyNSView(in: subview) { return found } | ||||||||||
| } | ||||||||||
| return nil | ||||||||||
| } | ||||||||||
|
|
||||||||||
| static func keyDescription(_ event: NSEvent) -> String { | ||||||||||
| var parts: [String] = [] | ||||||||||
| let flags = event.modifierFlags.intersection(.deviceIndependentFlagsMask) | ||||||||||
|
|
||||||||||
Uh oh!
There was an error while loading. Please reload this page.