diff --git a/Clipy/Sources/Managers/MenuManager.swift b/Clipy/Sources/Managers/MenuManager.swift index 9e3876f..e399849 100644 --- a/Clipy/Sources/Managers/MenuManager.swift +++ b/Clipy/Sources/Managers/MenuManager.swift @@ -3288,6 +3288,17 @@ final class BoardManHistoryCellView: NSTableCellView { )) } + static func synchronizedCellFrame(existingFrame: NSRect, safeWidth: CGFloat) -> NSRect { + let maximumOriginX = max(0, floor(safeWidth) - 1) + let preservedOriginX = min(max(0, floor(existingFrame.minX)), maximumOriginX) + return NSIntegralRect(NSRect( + x: preservedOriginX, + y: existingFrame.minY, + width: max(1, floor(safeWidth) - preservedOriginX), + height: existingFrame.height + )) + } + override func layout() { super.layout() let horizontalInset: CGFloat = 10 @@ -6480,7 +6491,10 @@ class BoardManPanel: NSPanel { rowView.needsDisplay = true if let cellView = rowView.view(atColumn: 0) as? NSView { - cellView.frame = NSRect(x: 0, y: cellView.frame.origin.y, width: safeWidth, height: cellView.frame.height) + cellView.frame = BoardManHistoryCellView.synchronizedCellFrame( + existingFrame: cellView.frame, + safeWidth: safeWidth + ) cellView.needsLayout = true cellView.needsDisplay = true } diff --git a/ClipyTests/EntitlementGateTests.swift b/ClipyTests/EntitlementGateTests.swift index 4f6a773..6966635 100644 --- a/ClipyTests/EntitlementGateTests.swift +++ b/ClipyTests/EntitlementGateTests.swift @@ -1088,6 +1088,15 @@ final class BoardManInteractionRuleTests { "Only the center title may compress between fixed accessories.") #expect((narrowPrimary.font?.pointSize ?? 99) <= 12.75, "Narrow rows should use the compact title font instead of squeezing accessories.") + + let resizedCellFrame = BoardManHistoryCellView.synchronizedCellFrame( + existingFrame: NSRect(x: 14, y: 0, width: 746, height: 46), + safeWidth: 600 + ) + #expect(resizedCellFrame.minX == 14, + "Responsive resizing must preserve the native table-cell leading inset.") + #expect(resizedCellFrame.maxX == 600, + "Responsive resizing must fill the remaining width without removing the leading inset.") } @Test