Repository navigation
Sort the stacked-window list alphabetically - #1909
Merged
Merged
Conversation
The list showed windows front to back, so every raise reshuffled it and a window never kept its row from one hover to the next. With a long stack that makes the list slow to scan. Sort by title instead (Finder-style: case-insensitive, numbers in natural order), with window id as the tiebreak so identical titles keep a stable order too. The cycle shortcuts keep their own front-to-back order; only the list changes.
MyronKoch
marked this pull request as draft
October 12, 2026 05:31
rxhanson
reviewed
Oct 12, 2026
| } | ||
|
|
||
| return windows.map { info in | ||
| return listOrder(windows.map { info in |
Owner
There was a problem hiding this comment.
In Swift, I'm used to seeing sorting done by calling .sorted on the mapped collection, something like this:
return windows.map { info in
StackBadgeStackedWindow(
windowId: info.id,
pid: info.pid,
title: displayTitle(for: info, axTitle: titles[info.id])
)
}.sorted { lhs, rhs in
let comparison = lhs.title.localizedStandardCompare(rhs.title)
if comparison != .orderedSame {
return comparison == .orderedAscending
}
return lhs.windowId < rhs.windowId
}
Of course, if this were reused elsewhere then something reusable like this function would be preferred.
Contributor
Author
There was a problem hiding this comment.
Good call, inlined it as you suggested. The helper was only there so unit tests could reach the sort without accessibility, so I dropped those along with it.
Chain .sorted onto the map per review; the helper existed only so unit tests could reach the sort, so those go with it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The stacked-window list currently shows windows front to back, so its order changes every time a window is raised: the window you just picked jumps to the top next hover, and everything else shifts down a row. With two or three windows that is fine. With a long stack (I regularly have 15+ terminals at one corner) it means re-reading the whole list every time, because nothing stays where it was.
This sorts the list by title instead, so each window keeps its row:
localizedStandardCompare(the Finder's ordering): case-insensitive, andTerminal 2comes beforeTerminal 10.Running it as my daily driver with a 17-window stack. Full suite: 524 passed, 0 failed.
Happy to make this a setting instead if you would rather keep front-to-back as the default.