mirror of
https://github.com/storytold/soundcraft.git
synced 2026-10-29 21:16:47 -06:00
Fix stale end on a Memory Location added during playback
Found while testing crates/engine/src/cmd/event.rs:305 (add_marker) Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 5.5
parent
e82c1689b3
commit
e600e6bf64
@@ -302,7 +302,10 @@ fn add_marker(e: &mut Engine, p: &Value) -> Result<Value> {
|
||||
(None, Some(a), Some(b)) => (a, b),
|
||||
(None, Some(p), None) | (None, None, Some(p)) => (p, p),
|
||||
_ if kind == MarkerKind::Selection => (sel.start, sel.end),
|
||||
_ => (if e.transport.playing { e.transport.position } else { sel.start }, sel.start),
|
||||
_ => {
|
||||
let point = if e.transport.playing { e.transport.position } else { sel.start };
|
||||
(point, point)
|
||||
}
|
||||
};
|
||||
let s = e.session_mut();
|
||||
let n = s.markers.len() + 1;
|
||||
@@ -473,6 +476,19 @@ mod tests {
|
||||
assert_eq!(find(&c), Some((1000, 2000)));
|
||||
}
|
||||
|
||||
/// A plain marker added during playback is a point at the playhead, whatever the edit selection is.
|
||||
#[test]
|
||||
fn markers_add_while_playing_is_a_point_at_the_playhead() {
|
||||
let mut e = demo_engine();
|
||||
e.session_mut().edit.selection.start = 48_000;
|
||||
e.session_mut().edit.selection.end = 48_000;
|
||||
e.transport.playing = true;
|
||||
e.transport.position = 4800;
|
||||
let r = e.execute("markers.add", &json!({"name": "M"})).unwrap();
|
||||
let m = e.session().markers.iter().find(|m| Some(m.id.0) == r["id"].as_u64()).map(|m| (m.start, m.end));
|
||||
assert_eq!(m, Some((4800, 4800)));
|
||||
}
|
||||
|
||||
/// `markers.edit` documents `color`: it sets the memory location's RGB colour, undoably; `null` clears it.
|
||||
#[test]
|
||||
fn edit_marker_sets_documented_color() {
|
||||
|
||||
Reference in New Issue
Block a user