Keep the edit cursor when opening an item in grid mode

Opening an item in the MIDI editor parks the edit cursor at the item
start, and the open action then made that stick. Listening to a phrase
and hitting Alt+Shift+G to write on top of it meant arrowing back to
where you already were, one cell at a time, on every entry.

The cursor now stays where it was and is only tidied onto the nearest
grid line, so the first left/right press moves a whole cell rather than
a remainder. The action reads the cursor before the open command runs,
since the open command is what moves it.

snapCursorToCell rounds in quarter notes, like everything else here, so
the landing spot survives a tempo change, and clamps the cell index into
the item: the floor is the cell containing the item start, which is
where the action used to land, and the ceiling is the last cell that
starts inside the item. Clamping the index rather than the time means a
cursor parked before an off-grid item start rounds forward into the
first whole cell instead of into the partial one, where a note would
begin outside the item.

The action also re-reads the take from the editor handle now, so the
grid size and the spoken position come from the take actually being
edited rather than from the selected item's active take.

Toggling grid mode on with Alt+G is left alone: it does not move the
cursor at all, and cell() floors, so an off-grid cursor still works.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-24 01:21:21 +02:00
co-authored by Claude Opus 5
parent c55ab24ae4
commit 0f06554a18
4 changed files with 80 additions and 4 deletions
+4
View File
@@ -181,6 +181,10 @@ the editor to toggle back off.
the MIDI editor's `active_note_row`. No private cursor state exists, so grid
mode and OSARA cannot drift out of sync — you can switch between them
mid-phrase.
- **Opening keeps your place.** `Alt+Shift+G` leaves the edit cursor where it
already was, rounded to the nearest grid line, instead of dropping it back to
the start of the item — so you can listen to a bar, hit it, and start writing
right there. A cursor outside the item lands on the item's first or last cell.
- **Turning grid mode off restores everything.** Each bound key forwards to
what it did before, so nothing is permanently taken away.