@@ -54,6 +54,7 @@ final class SQLEditorCoordinator: TextViewCoordinator, TextViewDelegate {
5454
5555 func scheduleEditorFocusClaim( ) {
5656 focusClaimPending = true
57+ Self . logger. debug ( " Editor focus claim armed " )
5758 }
5859
5960 /// Vim mode for UI observation
@@ -118,12 +119,18 @@ final class SQLEditorCoordinator: TextViewCoordinator, TextViewDelegate {
118119 EditorEventRouter . shared. register ( self , textView: textView)
119120
120121 if !self . isDestroyed, let window = textView. window {
121- if self . focusClaimPending {
122+ let claimPending = self . focusClaimPending
123+ let responderName = window. firstResponder. map { String ( describing: type ( of: $0) ) } ?? " nil "
124+ var made = false
125+ if claimPending {
122126 self . focusClaimPending = false
123- window. makeFirstResponder ( textView)
127+ made = window. makeFirstResponder ( textView)
124128 } else if window. firstResponder == nil || window. firstResponder === window {
125- window. makeFirstResponder ( textView)
129+ made = window. makeFirstResponder ( textView)
126130 }
131+ Self . logger. debug ( " Editor focus claim: pending= \( claimPending) isKey= \( window. isKeyWindow) responderBefore= \( responderName, privacy: . public) made= \( made) " )
132+ } else {
133+ Self . logger. debug ( " Editor focus claim skipped: hasWindow= \( textView. window != nil ) destroyed= \( self . isDestroyed) pending= \( self . focusClaimPending) " )
127134 }
128135 if controller. cursorPositions. isEmpty {
129136 controller. setCursorPositions ( [ CursorPosition ( range: NSRange ( location: 0 , length: 0 ) ) ] )
0 commit comments