Skip to content

Commit

Permalink
Rejig hanging close scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
mvahowe committed Oct 6, 2022
1 parent 90c4def commit f3bc6c0
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/transforms/perf2PkJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,36 @@ const perf2PkJsonActions = {
}
},
},
]
],

endDocument: [
{
description: 'Rework hanging end cv scopes',
test: () => true,
action: ({output}) => {
const sequenceBlocks = Object.values(output.pkJson)[0];
for (let blockN = 1; blockN < sequenceBlocks.length; blockN++) {
let thisBlockItems = sequenceBlocks[blockN].items;
const lastBlockItems = sequenceBlocks[blockN - 1].items;
let itemN = 0;
while (itemN < thisBlockItems.length) {
const item = thisBlockItems[itemN];
if (item.type !== 'scope' || item.subType !== 'end') {
break;
}
itemN++;
}
while (itemN > 0) {
const movingScope = thisBlockItems.shift();
lastBlockItems.push(movingScope);
sequenceBlocks[blockN].os = sequenceBlocks[blockN].os.filter(s => s !== movingScope.payload);
itemN--;
}
}
},
},
],

}

;
Expand Down

0 comments on commit f3bc6c0

Please sign in to comment.