From addd12ae99fbc83c6dd922b4f4cc009f117d5073 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Tue, 20 Dec 2016 01:31:49 -0500 Subject: [PATCH] Exclude child nodes from newIDs if their parent way was also copied for #3656 item 1 --- modules/behavior/paste.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/modules/behavior/paste.js b/modules/behavior/paste.js index a8898cf22..b1ebe3970 100644 --- a/modules/behavior/paste.js +++ b/modules/behavior/paste.js @@ -59,15 +59,29 @@ export function behaviorPaste(context) { context.perform(action); var copies = action.copies(); + var originals = _.invert(_.mapValues(copies, 'id')); for (var id in copies) { var oldEntity = oldGraph.entity(id), newEntity = copies[id]; extent._extend(oldEntity.extent(oldGraph)); - newIDs.push(newEntity.id); context.perform( actionChangeTags(newEntity.id, _.omit(newEntity.tags, omitTag)) ); + + // Exclude child nodes from newIDs if their parent way was also copied. + var parents = context.graph().parentWays(newEntity), + parentCopied = false; + for (var i = 0; i < parents.length; i++) { + if (originals[parents[i].id]) { + parentCopied = true; + break; + } + } + + if (!parentCopied) { + newIDs.push(newEntity.id); + } } // Put pasted objects where mouse pointer is..