Skip to content

Commit 0674a0a

Browse files
lucasmottaclaude
andcommitted
Fix code completion window visibility issues
Resolves intermittent visibility problems where the code completion window would not appear visually despite functioning correctly for keyboard navigation. Changes: - Replace problematic window style masks (.nonactivatingPanel, .utilityWindow) with .borderless - Set hidesOnDeactivate to false to prevent unexpected hiding - Add canHide = false and acceptsMouseMovedEvents = true for better window behavior - Improve window showing sequence in showWindow(attachedTo:) - Add proper cleanup of notification observers in close() The .nonactivatingPanel style was preventing the window from becoming key, causing the "canBecomeKeyWindow returned NO" warning and inconsistent visibility. Using .borderless provides the clean appearance needed for code completion while ensuring reliable display. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4a3cb13 commit 0674a0a

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

Sources/CodeEditSourceEditor/CodeSuggestion/Window/SuggestionController+Window.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ extension SuggestionController {
8484
static func makeWindow() -> NSWindow {
8585
let window = NSWindow(
8686
contentRect: .zero,
87-
styleMask: [.resizable, .fullSizeContentView, .nonactivatingPanel, .utilityWindow],
87+
styleMask: [.borderless],
8888
backing: .buffered,
8989
defer: false
9090
)
@@ -97,8 +97,10 @@ extension SuggestionController {
9797
window.hasShadow = true
9898
window.isOpaque = false
9999
window.tabbingMode = .disallowed
100-
window.hidesOnDeactivate = true
100+
window.hidesOnDeactivate = false
101101
window.backgroundColor = .clear
102+
window.canHide = false
103+
window.acceptsMouseMovedEvents = true
102104

103105
return window
104106
}

Sources/CodeEditSourceEditor/CodeSuggestion/Window/SuggestionController.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ public final class SuggestionController: NSWindowController {
103103
/// Opens the window as a child of another window.
104104
public func showWindow(attachedTo parentWindow: NSWindow) {
105105
guard let window = window else { return }
106+
107+
super.showWindow(nil)
106108
parentWindow.addChildWindow(window, ordered: .above)
109+
window.orderFront(nil)
107110

108111
// Close on window switch observer
109112
// Initialized outside of `setupEventMonitors` in order to grab the parent window
@@ -118,8 +121,6 @@ public final class SuggestionController: NSWindowController {
118121
self?.close()
119122
}
120123

121-
super.showWindow(nil)
122-
window.orderFront(nil)
123124
window.contentViewController?.viewWillAppear()
124125
}
125126

@@ -134,6 +135,12 @@ public final class SuggestionController: NSWindowController {
134135
contentViewController?.viewWillDisappear()
135136
}
136137

138+
// Clean up window observers
139+
if let observer = windowResignObserver {
140+
NotificationCenter.default.removeObserver(observer)
141+
windowResignObserver = nil
142+
}
143+
137144
super.close()
138145
}
139146

0 commit comments

Comments
 (0)