Skip to content

The agent that grows with you

style(desktop): restore EOF newlines and blank-line padding in window-state

teknium1e78e6bd4cc1c
diff --git a/apps/desktop/electron/window-state.test.ts b/apps/desktop/electron/window-state.test.ts
index 1109a0d8fec..8a895694b57 100644
--- a/apps/desktop/electron/window-state.test.ts
+++ b/apps/desktop/electron/window-state.test.ts
@@ -108,6 +108,7 @@ test('computeWindowOptions caps a positioned window to the display it overlaps',
{ workArea: { x: 0, y: 0, width: 2560, height: 1400 } },
{ workArea: { x: 2560, y: 0, width: 1366, height: 728 } }
]
+
const saved = sanitizeWindowState({ x: 2700, y: 100, width: 1400, height: 900 })
assert.deepEqual(computeWindowOptions(saved, dual), { width: 1366, height: 728, x: 2560, y: 0 })
})
@@ -200,4 +201,4 @@ test('a window that never emits moved/resized still saves its geometry', () => {
win.emit('move')
assert.ok(saves > 0)
-})
\ No newline at end of file
+})
diff --git a/apps/desktop/electron/window-state.ts b/apps/desktop/electron/window-state.ts
index a72e28e5d99..6192fae582c 100644
--- a/apps/desktop/electron/window-state.ts
+++ b/apps/desktop/electron/window-state.ts
@@ -61,6 +61,7 @@ function matchingWorkArea(bounds, displays) {
let best = null
let bestArea = 0
+
for (const { workArea: a } of displays) {
if (!a) {
continue
@@ -68,11 +69,13 @@ function matchingWorkArea(bounds, displays) {
const x = Math.min(bounds.x + bounds.width, a.x + a.width) - Math.max(bounds.x, a.x)
const y = Math.min(bounds.y + bounds.height, a.y + a.height) - Math.max(bounds.y, a.y)
+
if (x < MIN_VISIBLE || y < MIN_VISIBLE) {
continue
}
const area = x * y
+
if (area > bestArea) {
best = a
bestArea = area
@@ -124,6 +127,7 @@ function computeWindowOptions(state, displays): WindowOptions {
{ x: state.x, y: state.y, width: opts.width, height: opts.height },
displays
)
+
if (workArea) {
opts.width = clamp(opts.width, MIN_WIDTH, workArea.width)
opts.height = clamp(opts.height, MIN_HEIGHT, workArea.height)
@@ -189,4 +193,4 @@ export {
MIN_WIDTH,
onScreen,
sanitizeWindowState
-}
\ No newline at end of file
+}