Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Don't record undo events for enable/disable #8049

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions blocks/loops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
createBlockDefinitionsFromJsonArray,
defineBlocks,
} from '../core/common.js';
import * as eventUtils from '../core/events/utils.js';
import '../core/field_dropdown.js';
import '../core/field_label.js';
import '../core/field_number.js';
Expand Down Expand Up @@ -372,12 +373,16 @@ const CONTROL_FLOW_IN_LOOP_CHECK_MIXIN = {
this.setWarningText(
enabled ? null : Msg['CONTROLS_FLOW_STATEMENTS_WARNING'],
);

if (!this.isInFlyout) {
const group = Events.getGroup();
// Makes it so the move and the disable event get undone together.
Events.setGroup(e.group);
this.setEnabled(enabled);
Events.setGroup(group);
try {
// There is no need to record the enable/disable change on the undo/redo
// list since the change will be automatically recreated when replayed.
eventUtils.setRecordUndo(false);
this.setEnabled(enabled);
} finally {
eventUtils.setRecordUndo(true);
}
}
},
};
Expand Down
15 changes: 10 additions & 5 deletions blocks/procedures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import type {
ContextMenuOption,
LegacyContextMenuOption,
} from '../core/contextmenu_registry.js';
import * as eventUtils from '../core/events/utils.js';
import {FieldCheckbox} from '../core/field_checkbox.js';
import {FieldLabel} from '../core/field_label.js';
import {FieldTextInput} from '../core/field_textinput.js';
Expand Down Expand Up @@ -1316,12 +1317,16 @@ const PROCEDURES_IFRETURN = {
} else {
this.setWarningText(Msg['PROCEDURES_IFRETURN_WARNING']);
}

if (!this.isInFlyout) {
const group = Events.getGroup();
// Makes it so the move and the disable event get undone together.
Events.setGroup(e.group);
this.setEnabled(legal);
Events.setGroup(group);
try {
// There is no need to record the enable/disable change on the undo/redo
// list since the change will be automatically recreated when replayed.
eventUtils.setRecordUndo(false);
this.setEnabled(legal);
} finally {
eventUtils.setRecordUndo(true);
}
}
},
/**
Expand Down
Loading