1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Dont add wires to undo buffer twice

Fixes #3433
This commit is contained in:
Steve-Mcl 2022-02-13 16:56:26 +00:00
parent e5e3832809
commit b3f1401ab4

View File

@ -2338,14 +2338,21 @@ RED.view = (function() {
var removedSubflowStatus;
var subflowInstances = [];
var historyEvents = [];
var addToRemovedLinks = function(links) {
if(!links) { return; }
var _links = Array.isArray(links) ? links : [links];
_links.forEach(function(l) {
removedLinks.push(l);
selectedLinks.remove(l);
})
}
if (reconnectWires) {
var reconnectResult = RED.nodes.detachNodes(movingSet.nodes())
var addedLinks = reconnectResult.newLinks;
if (addedLinks.length > 0) {
historyEvents.push({ t:'add', links: addedLinks })
}
removedLinks = removedLinks.concat(reconnectResult.removedLinks)
addToRemovedLinks(reconnectResult.removedLinks)
}
var startDirty = RED.nodes.dirty();
@ -2377,7 +2384,7 @@ RED.view = (function() {
var removedEntities = RED.nodes.remove(node.id);
removedNodes.push(node);
removedNodes = removedNodes.concat(removedEntities.nodes);
removedLinks = removedLinks.concat(removedEntities.links);
addToRemovedLinks(removedNodes.removedLinks);
if (node.g) {
var group = RED.nodes.group(node.g);
if (selectedGroups.indexOf(group) === -1) {
@ -2410,20 +2417,20 @@ RED.view = (function() {
if (removedSubflowOutputs.length > 0) {
result = RED.subflow.removeOutput(removedSubflowOutputs);
if (result) {
removedLinks = removedLinks.concat(result.links);
addToRemovedLinks(result.links);
}
}
// Assume 0/1 inputs
if (removedSubflowInputs.length == 1) {
result = RED.subflow.removeInput();
if (result) {
removedLinks = removedLinks.concat(result.links);
addToRemovedLinks(result.links);
}
}
if (removedSubflowStatus) {
result = RED.subflow.removeStatus();
if (result) {
removedLinks = removedLinks.concat(result.links);
addToRemovedLinks(result.links);
}
}