Repository navigation
Conversation
isaaclins
left a comment
There was a problem hiding this comment.
I went through this against the table's own selection behaviour. The ⌘A and shift-click speed-up is real and the menu change is fine, but two things need fixing before it goes in, plus one about what this closes.
- A shift-click throws away songs picked with ⌘-click (line comment).
- A control-click (the right-click menu) moves the shift-click start (line comment).
- ⌘A measures 48 to 57 ms here, and #694's "done means" asks for within 50 ms. This PR shouldn't say it fixes #694: I'll change it to "Part of #694" and leave the issue open with what's left.
| shortcuts.realizedRows.selectionAnchorID = id | ||
| return event | ||
| } | ||
| shortcuts.selection = TrackListSelectionShortcuts.extend( |
There was a problem hiding this comment.
This replaces the whole selection with the range. The table keeps songs picked with ⌘-click: I checked a plain NSTableView with clicks posted through the event queue. Click row 2, ⌘-click row 5, shift-click row 10 gives 2 and 5 to 10. Shift-click row 8 after that gives 2 and 5 to 8. With this change the first shift-click gives only 5 to 10 and row 2 is gone.
So ⌘-click a few songs and then shift-click a range, the way Finder and Music work, now loses the ⌘-clicked songs. The shift-click should add the range to the selection as it was after the last click without shift, and a second shift-click should swap only the range.
There was a problem hiding this comment.
Fixed in 4b7068b. The first shift-click after a click without shift now takes the selection as that click left it and adds the range to it; a second shift-click swaps only the range. Songs from before that left the list are dropped. testAShiftClickSelectsFromTheLastClickedSong checks it, and the long-list test now adds a song as a ⌘-click would before its real shift-clicks and checks it stays, both times.
| guard let table = table(at: event.locationInWindow, in: window), | ||
| let id = trackID(atRow: table.row(at: table.convert(event.locationInWindow, from: nil)), of: table) | ||
| else { return event } | ||
| guard modifiers.subtracting([.capsLock, .numericPad, .function]) == .shift, event.clickCount == 1 else { |
There was a problem hiding this comment.
A control-click lands here too: it isn't exactly shift, so it sets the anchor to the row it opened the menu on. The table doesn't move its anchor for a control-click. Right-click a song, then shift-click, and the range starts at the right-clicked song instead of the last song clicked. A control-click should go to the table without touching the anchor.
There was a problem hiding this comment.
Fixed in 4b7068b: a control-click goes straight to the table and leaves the selection and the shift-click start alone.
|
Went over it again against how the table selects on its own. Found and fixed:
Clicked through the running app too: ⌘-click then shift-click, control-click then shift-click, and ⌘A all select what the table would. |
66bf63b to
1ae3255
Compare
b82a266 to
6be4a5e
Compare
|
Another pass, against the same plain-table reference:
Two things this leaves, filed: after a shift-click upwards the arrow keys go on from the bottom of the range (#718), and a shift-click on the artist name in a row selects instead of opening the artist (#719).
|
1ae3255 to
7aae1a8
Compare
6be4a5e to
2e0339c
Compare
7aae1a8 to
8c06902
Compare
2e0339c to
1ebf8dc
Compare
8c06902 to
2b442ef
Compare
1ebf8dc to
a9c6017
Compare
f858515 to
3c1fa2f
Compare
a9c6017 to
3a3bc97
Compare
98a2ff2 to
c6a3833
Compare
3a3bc97 to
6d60010
Compare
c6a3833 to
6604214
Compare
6d60010 to
12f58ee
Compare
12f58ee to
4cb69cb
Compare
8a18159 to
f25c40a
Compare
Part of #694: ⌘A is far faster but not reliably under 50 ms yet (see Numbers), so #694 stays open for the rest. It builds on #683's long-list test and row keys (merged).
How it looks
Nothing looks different. The selection draws the same as before; only how fast it gets there changes.
What was slow
When the table makes a selection itself (⌘A, shift-click), SwiftUI's list asks every row the selection adds how it selects (
outlineViewSelectionDidChange→onSelectSideEffects→selectionBehavior(item:makeIfNecessary: true)), and that builds the row's view, on screen or not. ⌘A on 2,000 songs built all 2,000 rows. A selection written through the binding doesn't go through that.What changed
TrackListSelectionShortcuts(inTrackListView.swift) sits behind the track list. It catches ⌘A on the list's table and a single shift-click on one of its songs before the table does, and sets the selection itself:TrackOpsMenuItemsnow works each one out once per build. Nothing in the menu changes.Numbers
make test-speed(LongListScrollCostTests, optimized build, 2,000-song playlist, clicks and keys posted through the app's event queue). My Mac was busy with other builds during these runs, so the absolute numbers are rough.With the shift-click changes from the review, on a quieter Mac: shift-click 30 songs 20.8 ms, ⌘A 47.1 ms, click another 23.6 ms, right-click 0.9 ms, pause 11.5 ms.
Other interactions in the same runs stayed where they were: click another song 25 to 28 ms, right-click 1 ms, play/pause 11 to 26 ms. The first click on a freshly opened list is still around 35 to 40 ms quiet and over 50 ms under load (#689).
⌘A is not reliably under 50 ms yet. It now costs exactly what setting all 2,000 songs in code costs (same median, measured side by side), so nothing in the ⌘A path itself is left. The rest is SwiftUI walking all 2,000 rows of the list on any selection change (
ForEachList.applyNodes). Getting under it means changing how rows learn they're selected, which is more than this fix.Tests
testClickingSelectingRightClickingAndPlayingShowWithin50msnow presses a real ⌘A and real shift-clicks through the app's event queue (scrolled to the clicked song, as someone would). It checks the range comes from the last clicked song, and that a second shift-click extends from the same song. It no longer exempts ⌘A and shift-click from the "fewer than 50 rows built" check. GitHub's runners don't hand posted events to the window, so there these steps are skipped and the report says so. Long playlists scroll and take clicks without stalls #683's fallback there (the table selects the clicked row) now only stands in for plain clicks.testShiftClicksKeepWhatTheTableKeepsreplays click sequences I ran against a plainNSTableView(⌘-click then shift-click, shift-click after ⌘A, after shift-arrow, after a ⌘-click that takes a song out, after a ⌘-shift-click, after an arrow key) and checks the same songs come out. It runs everywhere.testAShiftClickSelectsFromTheLastClickedSongchecks the range itself (up, down, same song, no anchor, an anchor that left the list, songs picked with ⌘-click before), and runs everywhere.make build,make test(2,763 tests on today's main, 0 failures; it runs the real ⌘A and shift-clicks above too, without the timing).make test-speedmeasured shift-click 30 songs 21.8 ms and ⌘A 55.1 ms earlier today; on the latest main it doesn't link at all (make test-speed doesn't link on main: undefined SwiftUI opaque type in the Release test bundle #782), so these times are from before the rebase.TrackListView(Opening or closing the lyrics with ⌥⌘L takes about 140 ms #674); the shift-click state now lives in the catcher itself, which hears of selection changes when the list hands it the new selection.testATableRowMapsToItsSongAroundHeaderAndFooterRowschecks which song a table row is when a header sits above the songs (Home's top tracks) or a footer below them.scripts/check-periphery.sh(2.21.2): onlycolumnVisibility, which my local Xcode reports on main too.Checked in the running app
Release build, sample library, a 1,000-song playlist:
Not checked