Skip to content

Commit

Permalink
Fix Clean workflow command
Browse files Browse the repository at this point in the history
Was failing because conflicting edits trying to remove the trailing comma for a property that was already removed.

Now, if the property with the trailing comma is removed, it will check the previous property and so on.
  • Loading branch information
davelopez committed May 14, 2022
1 parent b8b1190 commit 2b33a20
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions server/src/commands/cleanWorkflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ export class CleanWorkflowCommand extends CustomCommand {
// Remove trailing comma in previous property node
const isLastNode = workflowDocument.isLastNodeInParent(node);
if (isLastNode) {
const previousNode = workflowDocument.getPreviousSiblingNode(node);
let previousNode = workflowDocument.getPreviousSiblingNode(node);
while (previousNode && nodesToRemove.includes(previousNode)) {
previousNode = workflowDocument.getPreviousSiblingNode(previousNode);
}
if (previousNode) {
const range = this.getFullNodeRange(workflowDocument.textDocument, previousNode);
const nodeText = workflowDocument.textDocument.getText(range);
Expand All @@ -132,10 +135,7 @@ export class CleanWorkflowCommand extends CustomCommand {
return result;
}

private getNonEssentialNodes(
workflowDocument: WorkflowDocument,
cleanablePropertyNames: Set<string>
): PropertyASTNode[] {
private getNonEssentialNodes(workflowDocument: WorkflowDocument, cleanablePropertyNames: Set<string>): ASTNode[] {
const root = workflowDocument.rootNode;
if (!root) {
return [];
Expand Down

0 comments on commit 2b33a20

Please sign in to comment.