fix: Don't clober event group when renaming vars (#6829)

* fix: Don't clober event group when renaming vars

Also audit all existing event group commands and tweak a few of them where I think there's a potential issue.
This commit is contained in:
Neil Fraser
2023-03-17 20:09:51 +01:00
committed by GitHub
parent a0b4a214a9
commit 6f64d1801a
10 changed files with 48 additions and 55 deletions

View File

@@ -69,7 +69,10 @@ export class VariableMap {
const type = variable.type;
const conflictVar = this.getVariable(newName, type);
const blocks = this.workspace.getAllBlocks(false);
eventUtils.setGroup(true);
const existingGroup = eventUtils.getGroup();
if (!existingGroup) {
eventUtils.setGroup(true);
}
try {
// The IDs may match if the rename is a simple case change (name1 ->
// Name1).
@@ -80,7 +83,7 @@ export class VariableMap {
variable, newName, conflictVar, blocks);
}
} finally {
eventUtils.setGroup(false);
eventUtils.setGroup(existingGroup);
}
}
@@ -284,9 +287,7 @@ export class VariableMap {
}
this.deleteVariable(variable);
} finally {
if (!existingGroup) {
eventUtils.setGroup(false);
}
eventUtils.setGroup(existingGroup);
}
}
/* End functions for variable deletion. */