Skip to content

Commit 3ce9032

Browse files
authored
Improve text completion positioning (#700)
1 parent 1ed06b0 commit 3ce9032

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

MarkEditMac/Modules/Sources/TextCompletion/TextCompletionContext.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,11 @@ public final class TextCompletionContext {
7272
origin.x = parentWindow.frame.size.width - panelPadding - panelSize.width
7373
}
7474

75+
let screenY = parentWindow.convertPoint(toScreen: origin).y
76+
let dockHeight = (parentWindow.screen ?? NSScreen.main)?.dockHeight ?? 0
77+
7578
// Too close to the bottom, or was already upside down during one typing session
76-
if (origin.y - panelPadding < 0) || wasFlipped {
79+
if (screenY - dockHeight - panelPadding < 0) || wasFlipped {
7780
origin.y = parentWindow.frame.height - caretRect.minY - safeArea + caretPadding
7881
wasFlipped = true
7982
}
@@ -114,3 +117,11 @@ public final class TextCompletionContext {
114117
private let localizable: TextCompletionLocalizable
115118
private let commitCompletion: @Sendable () -> Void
116119
}
120+
121+
// MARK: - Private
122+
123+
private extension NSScreen {
124+
var dockHeight: Double {
125+
frame.height - visibleFrame.height
126+
}
127+
}

0 commit comments

Comments
 (0)