diff --git a/src/main/java/io/github/jadefalke2/actions/LineAction.java b/src/main/java/io/github/jadefalke2/actions/LineAction.java index 05ae0cf..75fdfcc 100644 --- a/src/main/java/io/github/jadefalke2/actions/LineAction.java +++ b/src/main/java/io/github/jadefalke2/actions/LineAction.java @@ -49,7 +49,7 @@ public void revert() { switch (type){ case CLONE: //fallthrough to INSERT case INSERT: deleteRows(true); break; - case DELETE: insertRows(previousLines, rows[0]); break; + case DELETE: insertRows(previousLines, rows); break; case REPLACE: revertReplaceRows(); break; } } @@ -115,10 +115,12 @@ private void insertEmptyRows(int amount) { insertRows(tmpLines, rows[rows.length-1]+1); } - private void insertRows (InputLine[] inputLines, int index){ + private void insertRows (InputLine[] inputLines, int index) { + insertRows(inputLines, IntStream.range(index, index+inputLines.length).toArray()); + } + private void insertRows (InputLine[] inputLines, int[] indices){ for (int i = 0; i < inputLines.length; i++){ - int actualIndex = index + i; - script.insertRow(actualIndex, inputLines[i]); + script.insertRow(indices[i], inputLines[i]); } }