fix: insert onto selected track(s) at edit cursor, not a new track

Wire both insert actions to CurrentTrack (InsertMedia base 0). Per selected
track: SetOnlyTrackSelected, reset cursor to snapshot, InsertMedia; then restore
original selection + cursor. No-op when no track selected. Corrected stale
extraflags / new-track / preservePitch comments.
This commit is contained in:
2026-07-23 05:56:25 -04:00
parent 59e3c5907f
commit 2536b4bedb
5 changed files with 142 additions and 66 deletions
+21 -7
View File
@@ -25,11 +25,11 @@ constexpr int MATCH_HALF = 16;
constexpr int MATCH_DBL = 32;
constexpr int NO_PITCH = 64;
static void testDefaultIsNewTrackNativeLength() {
// Defaults: new track (base 1), no conform, pitch preserved.
static void testDefaultIsCurrentTrackNativeLength() {
// Defaults: current track (base 0), no conform, pitch preserved.
InsertOptions opts;
const int mode = computeInsertMode(opts);
CHECK(mode == 1); // base 1 only, no other bits
CHECK(mode == 0); // base 0 only, no other bits
CHECK((mode & STRETCH_FIT) == 0); // never stretch-to-time-sel
CHECK((mode & MATCH_1X) == 0); // no tempo bits at native length
CHECK((mode & MATCH_HALF) == 0);
@@ -47,11 +47,11 @@ static void testCurrentTrackBaseIsZero() {
}
static void testConform1xSetsOnlyMatchBit() {
InsertOptions opts; // new track base 1
InsertOptions opts; // current track base 0 (default)
opts.conform = TempoConform::Ratio1x;
const int mode = computeInsertMode(opts);
CHECK((mode & MATCH_1X) == MATCH_1X); // the 1x match bit is set
CHECK((mode & 3) == 1); // base target unchanged
CHECK((mode & 3) == 0); // base target: current track (0)
CHECK((mode & STRETCH_FIT) == 0); // still never the stretch bit
CHECK((mode & (MATCH_HALF | MATCH_DBL)) == 0); // no other ratio bits
CHECK((mode & NO_PITCH) == 0); // pitch preserved by default
@@ -87,7 +87,20 @@ static void testPreservePitchGatesTheNoPitchBit() {
noConformNoPitch.conform = TempoConform::None;
noConformNoPitch.preservePitch = false;
CHECK((computeInsertMode(noConformNoPitch) & NO_PITCH) == 0);
CHECK(computeInsertMode(noConformNoPitch) == 1); // just base 1, nothing else
CHECK(computeInsertMode(noConformNoPitch) == 0); // base 0 (current track), nothing else
}
static void testDefaultActionIsCurrentTrackBase0() {
// The default InsertOptions must compute base 0 (current track) so that both
// insert actions (default + conform) target the user's selected track(s), not
// a new track. This is the wired M6 insert-target change.
InsertOptions defaultOpts;
CHECK(defaultOpts.target == InsertTarget::CurrentTrack);
CHECK((computeInsertMode(defaultOpts) & 3) == 0); // base 0
InsertOptions conformOpts;
conformOpts.conform = TempoConform::Ratio1x;
CHECK((computeInsertMode(conformOpts) & 3) == 0); // conform variant also base 0
}
static void testStretchBitNeverSetAcrossAllOptions() {
@@ -107,11 +120,12 @@ static void testStretchBitNeverSetAcrossAllOptions() {
}
int main() {
testDefaultIsNewTrackNativeLength();
testDefaultIsCurrentTrackNativeLength();
testCurrentTrackBaseIsZero();
testConform1xSetsOnlyMatchBit();
testConformHalfAndDoubleRatios();
testPreservePitchGatesTheNoPitchBit();
testDefaultActionIsCurrentTrackBase0();
testStretchBitNeverSetAcrossAllOptions();
if (g_fail == 0) std::printf("insert_plan: all tests passed\n");