Skip to content

Commit 6ab703e

Browse files
committed
Fixed that widget can't be correctly hidden
1 parent 06811a9 commit 6ab703e

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

Core/Sources/SuggestionWidget/SuggestionWidgetController.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,7 @@ extension SuggestionWidgetController {
373373
sourceEditorMonitorTask = nil
374374
observeEditorChangeIfNeeded(app)
375375

376-
guard let fileURL = await {
377-
return try? await Environment.fetchFocusedElementURI()
378-
}() else {
376+
guard let fileURL = await try? await Environment.fetchFocusedElementURI() else {
379377
continue
380378
}
381379

@@ -616,7 +614,10 @@ extension SuggestionWidgetController: NSWindowDelegate {
616614
.frame ?? .zero
617615
var mouseLocation = NSEvent.mouseLocation
618616
let windowFrame = chatWindow.frame
619-
if mouseLocation.y > windowFrame.maxY - 40 {
617+
if mouseLocation.y > windowFrame.maxY - 40,
618+
mouseLocation.x > windowFrame.minX,
619+
mouseLocation.x < windowFrame.maxX
620+
{
620621
mouseLocation.y = screenFrame.size.height - mouseLocation.y
621622
if let cgEvent = CGEvent(
622623
mouseEventSource: nil,
@@ -645,8 +646,12 @@ class ChatWindow: NSWindow {
645646
override func mouseDown(with event: NSEvent) {
646647
let windowFrame = frame
647648
let currentLocation = event.locationInWindow
648-
if currentLocation.y > windowFrame.size.height - 40 {
649+
if currentLocation.y > windowFrame.size.height - 40,
650+
currentLocation.x > windowFrame.minX,
651+
currentLocation.x < windowFrame.maxX
652+
{
649653
performDrag(with: event)
650654
}
651655
}
652656
}
657+

0 commit comments

Comments
 (0)