Skip to content

Commit d3b5bef

Browse files
committed
fix: app crash from v7.13.0 (closes #4016)
1 parent 4481d94 commit d3b5bef

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/logic/Windows.swift

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,15 @@ class Windows {
251251
for (index, cgWindowId) in Spaces.windowsInSpaces(Spaces.visibleSpaces).enumerated() {
252252
windowLevelMap[cgWindowId] = index
253253
}
254-
var orderForUnlistedWindows = Int.max
255-
for window in list {
256-
if let listedOrder = windowLevelMap[window.cgWindowId] {
257-
window.lastFocusOrder = listedOrder
258-
} else {
259-
window.lastFocusOrder = orderForUnlistedWindows
260-
orderForUnlistedWindows -= 1
261-
}
262-
}
263-
list.sort { $0.lastFocusOrder < $1.lastFocusOrder }
254+
list = list
255+
.sorted { w1, w2 in
256+
(windowLevelMap[w1.cgWindowId] ?? .max) < (windowLevelMap[w2.cgWindowId] ?? .max)
257+
}
258+
.enumerated()
259+
.map { (index, window) -> Window in
260+
window.lastFocusOrder = index
261+
return window
262+
}
264263
}
265264

266265
static func refreshThumbnailsAsync(_ screen: NSScreen, _ currentIndex: Int) {

0 commit comments

Comments
 (0)