From 89e1a18dc1338b6b23a625a4458115bbf3492be1 Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Wed, 22 Nov 2017 16:52:33 -0800 Subject: [PATCH] Line by line edits to ensure cursor doesnt move to end of chunk --- src/diffUtils.ts | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/diffUtils.ts b/src/diffUtils.ts index 05f4536da..993179de5 100644 --- a/src/diffUtils.ts +++ b/src/diffUtils.ts @@ -101,32 +101,21 @@ function parseUniDiffs(diffOutput: jsDiff.IUniDiff[]): FilePatch[] { hunk.lines.forEach((line) => { switch (line.substr(0, 1)) { case '-': - if (edit == null) { - edit = new Edit(EditTypes.EDIT_DELETE, new Position(startLine - 1, 0)); - } + edit = new Edit(EditTypes.EDIT_DELETE, new Position(startLine - 1, 0)); edit.end = new Position(startLine, 0); + edits.push(edit); startLine++; break; case '+': - if (edit == null) { - edit = new Edit(EditTypes.EDIT_INSERT, new Position(startLine - 1, 0)); - } else if (edit.action === EditTypes.EDIT_DELETE) { - edit.action = EditTypes.EDIT_REPLACE; - } + edit = new Edit(EditTypes.EDIT_INSERT, new Position(startLine - 1, 0)); edit.text += line.substr(1) + '\n'; + edits.push(edit); break; case ' ': startLine++; - if (edit != null) { - edits.push(edit); - } - edit = null; break; } }); - if (edit != null) { - edits.push(edit); - } }); let fileName = uniDiff.oldFileName;