Skip to content

Commit 30064b0

Browse files
committed
Revert "fix(editor): arm new-tab focus claim before the editor view loads, add focus logging (#1765)"
This reverts commit a375df9.
1 parent a375df9 commit 30064b0

2 files changed

Lines changed: 8 additions & 13 deletions

File tree

TablePro/Views/Editor/SQLEditorCoordinator.swift

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ final class SQLEditorCoordinator: TextViewCoordinator, TextViewDelegate {
5454

5555
func scheduleEditorFocusClaim() {
5656
focusClaimPending = true
57-
Self.logger.debug("Editor focus claim armed")
5857
}
5958

6059
/// Vim mode for UI observation
@@ -119,18 +118,12 @@ final class SQLEditorCoordinator: TextViewCoordinator, TextViewDelegate {
119118
EditorEventRouter.shared.register(self, textView: textView)
120119

121120
if !self.isDestroyed, let window = textView.window {
122-
let claimPending = self.focusClaimPending
123-
let responderName = window.firstResponder.map { String(describing: type(of: $0)) } ?? "nil"
124-
var made = false
125-
if claimPending {
121+
if self.focusClaimPending {
126122
self.focusClaimPending = false
127-
made = window.makeFirstResponder(textView)
123+
window.makeFirstResponder(textView)
128124
} else if window.firstResponder == nil || window.firstResponder === window {
129-
made = window.makeFirstResponder(textView)
125+
window.makeFirstResponder(textView)
130126
}
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)")
134127
}
135128
if controller.cursorPositions.isEmpty {
136129
controller.setCursorPositions([CursorPosition(range: NSRange(location: 0, length: 0))])

TablePro/Views/Editor/SQLEditorView.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ struct SQLEditorView: View {
5050
coordinator.databaseType = databaseType
5151
coordinator.tabID = tabID
5252
coordinator.connectionId = connectionId
53-
if claimFocusOnAppear {
54-
coordinator.scheduleEditorFocusClaim()
55-
}
5653

5754
return SourceEditor(
5855
$text,
@@ -63,6 +60,11 @@ struct SQLEditorView: View {
6360
completionDelegate: completionAdapter
6461
)
6562
.accessibilityLabel(String(localized: "SQL query editor"))
63+
.onAppear {
64+
if claimFocusOnAppear {
65+
coordinator.scheduleEditorFocusClaim()
66+
}
67+
}
6668
.onChange(of: editorState.cursorPositions) { _, newValue in
6769
guard let positions = newValue else { return }
6870
// Skip cursor propagation when the editor doesn't have focus

0 commit comments

Comments
 (0)