fix(commands): narrow deferred history policy

This commit is contained in:
syntaxbullet
2026-07-04 15:59:30 +02:00
parent 88208ea1ad
commit 1a43d1f0e5

View File

@@ -59,13 +59,15 @@ function applyHistoryPolicy(options: {
getDeferredHistory: () => { snapshot: HistorySnapshot; changed: boolean } | undefined;
setDeferredHistory: (nextDeferredHistory: { snapshot: HistorySnapshot; changed: boolean } | undefined) => void;
}): AppState {
if (options.historyPolicy.mode === "ignore") {
const { historyPolicy } = options;
if (historyPolicy.mode === "ignore") {
options.setDeferredHistory(undefined);
return options.nextState;
}
if (options.historyPolicy.mode === "deferred") {
return applyDeferredHistoryPolicy(options);
if (historyPolicy.mode === "deferred") {
return applyDeferredHistoryPolicy({ ...options, historyPolicy });
}
return shouldRecordHistory(options.currentState, options.nextState) ? recordHistory(snapshot(options.currentState), options.nextState) : options.nextState;