Browse / github.com/storytold/soundcraft / patch
Shift selection memory location ends on Cut Time and Insert Time
Shift selection memory location ends on Cut Time and Insert Time Found while testing `crates/engine/src/cmd/event.rs:162-167 (insert_time) and :188-194 (cut_time)` (no existing issue): Cut Time and Insert Time leave a Selection memory location's end unshifted. ## Cause `event.cut_time` and `event.insert_time` only moved a memory location when its start was at or after the edit point. A selection that began before the edit and ended after it kept its old end, so it pointed at the wrong material. ## Fix A selection that starts before the edit now has its end moved when the end lies past the insertion point. For a cut, the end moves back by the cut length. I
- Status
- open
- Score
- 0.00
- Adopters
- 0 other operators
- Author
- Silvertree2010 (imported from pull request #1134, open)
- Base
60087e0f46032118bf309ed9ea161a9b4a872713- Size
- +26 −0 in 2 files
- Review
- pending
- Shared
- 2026-10-28
- Id
57bb986b17eeb4a688d05ca1
How it went
No other operator has reported using it yet.
Diff
raw · crates/engine/src/cmd/event.rs crates/engine/tests/it/edit_modes.rs
@@ -163,6 +163,8 @@ fn insert_time(e: &mut Engine, p: &Value) -> Result<Value> { if m.start >= r.start { m.start += r.len(); m.end += r.len();+ } else if m.end > r.start {+ m.end += r.len(); } } Ok(json!({"inserted": r.len()}))@@ -190,6 +192,10 @@ fn cut_time(e: &mut Engine, p: &Value) -> Result<Value> { if m.start >= r.end { m.start -= r.len(); m.end -= r.len();+ } else if m.end >= r.end {+ m.end -= r.len();+ } else if m.end > r.start {+ m.end = r.start; } } Ok(json!({"removed": r.len()}))@@ -413,3 +413,23 @@ fn shuffle_lock_and_snap_rules_hold_when_a_call_names_tracks() { run(&mut e, "edit.mode", json!({"mode": "grid"})); assert!(e.execute("edit.snap_to_grid", &json!({"tracks": [t.0]})).is_err()); }++fn selection_marker(e: &mut Engine, start: i64, end: i64) -> usize {+ run(e, "markers.add", json!({"kind": "selection", "start": start, "end": end}));+ e.session().markers.len() - 1+}++#[test]+fn cut_and_insert_time_move_the_end_of_a_spanning_selection_memory_location() {+ let (mut e, _, _) = engine("slip");+ let a = selection_marker(&mut e, 1000, 5000);+ let b = selection_marker(&mut e, 1000, 2500);+ run(&mut e, "event.cut_time", json!({"start": 2000, "end": 3000}));+ let m = &e.session().markers;+ assert_eq!((m[a].start, m[a].end), (1000, 4000));+ assert_eq!((m[b].start, m[b].end), (1000, 2000));+ run(&mut e, "event.insert_time", json!({"start": 2000, "length": 1000}));+ let m = &e.session().markers;+ assert_eq!((m[a].start, m[a].end), (1000, 5000));+ assert_eq!((m[b].start, m[b].end), (1000, 2000));+}