Skip to content

Commit 64b15cd

Browse files
committed
Align Itembox Labels With Text
1 parent b0ed459 commit 64b15cd

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

Sources/CodeEditSourceEditor/CodeSuggestion/TableView/CodeSuggestionLabelView.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import AppKit
99
import SwiftUI
1010

1111
struct CodeSuggestionLabelView: View {
12+
static let HORIZONTAL_PADDING: CGFloat = 13
13+
1214
let suggestion: CodeSuggestionEntry
1315
let labelColor: NSColor
1416
let secondaryLabelColor: NSColor
@@ -45,7 +47,7 @@ struct CodeSuggestionLabelView: View {
4547
}
4648
}
4749
.padding(.vertical, 3)
48-
.padding(.horizontal, 13)
50+
.padding(.horizontal, Self.HORIZONTAL_PADDING)
4951
.buttonStyle(PlainButtonStyle())
5052
}
5153
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import AppKit
99

1010
extension SuggestionController {
1111
/// Will constrain the window's frame to be within the visible screen
12-
public func constrainWindowToScreenEdges(cursorRect: NSRect) {
12+
public func constrainWindowToScreenEdges(cursorRect: NSRect, font: NSFont) {
1313
guard let window = self.window,
1414
let screenFrame = window.screen?.visibleFrame else {
1515
return
@@ -18,7 +18,8 @@ extension SuggestionController {
1818
let windowSize = window.frame.size
1919
let padding: CGFloat = 22
2020
var newWindowOrigin = NSPoint(
21-
x: cursorRect.origin.x - Self.WINDOW_PADDING,
21+
x: cursorRect.origin.x - Self.WINDOW_PADDING
22+
- CodeSuggestionLabelView.HORIZONTAL_PADDING - font.pointSize,
2223
y: cursorRect.origin.y
2324
)
2425

Sources/CodeEditSourceEditor/CodeSuggestion/Window/SuggestionController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public final class SuggestionController: NSWindowController {
9191
self.popover = popover
9292
} else {
9393
self.showWindow(attachedTo: parentWindow)
94-
self.constrainWindowToScreenEdges(cursorRect: cursorRect)
94+
self.constrainWindowToScreenEdges(cursorRect: cursorRect, font: textView.font)
9595

9696
if let controller = self.contentViewController as? SuggestionViewController {
9797
controller.styleView(using: textView)

0 commit comments

Comments
 (0)