One undo-block opener for the whole tree: fourteen sites route through it, and the reclaim span can no longer swallow a user's act

The drain refuses a tick inside a foreign block; applyMode wakes the reclaimer
before it opens the span.
This commit is contained in:
2026-08-07 16:38:11 -04:00
parent b2f6b3f1d0
commit b7b93a7ac3
25 changed files with 561 additions and 313 deletions
+7 -10
View File
@@ -33,6 +33,7 @@
#include "shell/panel/panel_bank_ops.h" // bankPanelSelectedSampleIds / SourceBankId
#include "core/capture/capture_paths.h"
#include "shell/persist/session.h"
#include "shell/undo/undo_block.h"
#define REAPERAPI_MINIMAL
#define REAPERAPI_WANT_CountSelectedTracks
@@ -44,8 +45,6 @@
#define REAPERAPI_WANT_SetOnlyTrackSelected
#define REAPERAPI_WANT_SetTrackSelected
#define REAPERAPI_WANT_ShowConsoleMsg
#define REAPERAPI_WANT_Undo_BeginBlock2
#define REAPERAPI_WANT_Undo_EndBlock2
#include "reaper_plugin_functions.h"
namespace reasampler {
@@ -139,9 +138,8 @@ InsertResult runInsert(ReaSamplerSession* session, const InsertRequest& request)
const double cursorPos = GetCursorPosition();
// One undo block around the whole placement (all tracks + selection/cursor
// restore) so a single undo removes every item and restores prior state. Always
// balanced — opened before the first insert, closed after the restore.
Undo_BeginBlock2(nullptr);
// restore) so a single undo removes every item and restores prior state.
UndoBlock undo(nullptr);
// Insert onto each selected track at the same cursor position (assumption B): per
// track, isolate it as the only selection (A + E), reset the cursor (C is
@@ -159,11 +157,10 @@ InsertResult runInsert(ReaSamplerSession* session, const InsertRequest& request)
// Label reflects count + conform choice for a clear undo history. extraflags -1 =
// UNDO_STATE_ALL (tracks, items, envelope points, project state).
const std::string label =
"ReaSampler: insert on " + std::to_string(result.inserted) +
(result.inserted == 1 ? " track" : " tracks") +
(request.options.conform == TempoConform::None ? "" : " (conform)");
Undo_EndBlock2(nullptr, label.c_str(), -1);
undo.recordPoint("ReaSampler: insert on " + std::to_string(result.inserted) +
(result.inserted == 1 ? " track" : " tracks") +
(request.options.conform == TempoConform::None ? "" : " (conform)"),
-1);
result.status = InsertStatus::Ok;
return result;