diff --git a/Rectangle/WindowCalculation/ChangeSizeCalculation.swift b/Rectangle/WindowCalculation/ChangeSizeCalculation.swift index 25d0b11a..2c00e58f 100644 --- a/Rectangle/WindowCalculation/ChangeSizeCalculation.swift +++ b/Rectangle/WindowCalculation/ChangeSizeCalculation.swift @@ -68,7 +68,7 @@ class ChangeSizeCalculation: WindowCalculation, ChangeWindowDimensionCalculation resizedWindowRect.size.height = resizedWindowRect.height + sizeOffset resizedWindowRect.origin.y = resizedWindowRect.minY - floor(sizeOffset / 2.0) - if curtainChangeSize, params.action != .smallerHeight { + if curtainChangeSize, ![.smaller, .smallerHeight].contains(params.action) { resizedWindowRect = againstTopAndBottomScreenEdges( originalWindowRect: window.rect, resizedWindowRect: resizedWindowRect, diff --git a/RectangleTests/RectangleTests.swift b/RectangleTests/RectangleTests.swift index e555b3c4..3f1b163f 100644 --- a/RectangleTests/RectangleTests.swift +++ b/RectangleTests/RectangleTests.swift @@ -319,7 +319,7 @@ class ChangeSizeCalculationTests: XCTestCase { func testExplicitZeroDisablesScreenFractionMinimum() { XCTAssertEqual(smallerResult(for: issueWindowRect), - CGRect(x: 1925, y: 0, width: 635, height: 1415)) + CGRect(x: 1925, y: 15, width: 635, height: 1385)) } func testDoubleDefaultDistinguishesAbsentFromExplicitZero() { @@ -380,7 +380,7 @@ class ChangeSizeCalculationTests: XCTestCase { let windowRect = CGRect(x: 1890, y: 0, width: 670, height: 1415) XCTAssertEqual(smallerResult(for: windowRect), - CGRect(x: 1920, y: 0, width: 640, height: 1415)) + CGRect(x: 1920, y: 15, width: 640, height: 1385)) } func testSmallerHonorsConfiguredScreenFractionMinimum() { @@ -389,11 +389,21 @@ class ChangeSizeCalculationTests: XCTestCase { XCTAssertEqual(smallerResult(for: issueWindowRect), issueWindowRect) } + func testSmallerShrinksHeightOfFullHeightWindow() { + // Regression for #1737: a vertically-maximized (Half / full-height) window must shrink in + // BOTH dimensions under the combined `.smaller` command, not only in width. Mirrors the + // `.smallerHeight` exception added in b97a353 (fixes #1645), extended to `.smaller`. + let fullHeightHalf = CGRect(x: 0, y: 0, width: 1280, height: 1415) + + XCTAssertEqual(smallerResult(for: fullHeightHalf), + CGRect(x: 0, y: 15, width: 1250, height: 1385)) + } + func testSmallConfiguredScreenFractionAllowsIssueRegressionStep() { Defaults.minimumWindowWidth.value = 0.01 XCTAssertEqual(smallerResult(for: issueWindowRect), - CGRect(x: 1925, y: 0, width: 635, height: 1415)) + CGRect(x: 1925, y: 15, width: 635, height: 1385)) } func testExplicitZeroStillRejectsNonpositiveSize() {