Skip to content

Commit 369e627

Browse files
committed
Fix that the widget won't align to the editor when user checking symbol info with alt+click
1 parent 5109e7f commit 369e627

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

Tool/Sources/AXExtension/AXUIElement.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ public extension AXUIElement {
183183
}
184184
return all
185185
}
186+
187+
func firstParent(where match: (AXUIElement) -> Bool) -> AXUIElement? {
188+
guard let parent = self.parent else { return nil }
189+
if match(parent) { return parent }
190+
return parent.firstParent(where: match)
191+
}
186192

187193
func firstChild(where match: (AXUIElement) -> Bool) -> AXUIElement? {
188194
for child in children {

Tool/Sources/XcodeInspector/XcodeInspector.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ public final class XcodeInspector: ObservableObject {
182182
runningApplication: xcode.runningApplication,
183183
element: editorElement
184184
)
185+
} else if let element = focusedElement,
186+
let editorElement = element.firstParent(where: \.isSourceEditor)
187+
{
188+
focusedEditor = .init(
189+
runningApplication: xcode.runningApplication,
190+
element: editorElement
191+
)
185192
} else {
186193
focusedEditor = nil
187194
}

0 commit comments

Comments
 (0)