From 6308b18e9bccaec48515f87cf134ac36246c6e91 Mon Sep 17 00:00:00 2001 From: mariru27 Date: Fri, 11 Mar 2022 16:40:31 +0200 Subject: [PATCH] Insert empty lines to equalize the length of the input and output --- .../DiffStyle/DiffMatchPatchWrapper.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/ClangFormatEditor/DiffStyle/DiffMatchPatchWrapper.cs b/ClangFormatEditor/DiffStyle/DiffMatchPatchWrapper.cs index 7934154..e82ce8d 100644 --- a/ClangFormatEditor/DiffStyle/DiffMatchPatchWrapper.cs +++ b/ClangFormatEditor/DiffStyle/DiffMatchPatchWrapper.cs @@ -282,6 +282,14 @@ private List EqualizeDocumentLength(string input, string output) if (newLineFoundPerOperation != 0) { emptyLinesToAdd += newLineFoundPerOperation; + if(emptyLinesToAdd > 0) + { + for (int i = 0; i < emptyLinesToAdd; i++) + { + lines.Add(Environment.NewLine); + } + } + emptyLinesToAdd = 0; } break; case Operation.INSERT: @@ -331,15 +339,6 @@ private List EqualizeDocumentLength(string input, string output) equalLines.RemoveAt(0); } - // Insert empty lines to equalize the length of the input and output - if (newLineFoundPerOperation > 1) - { - for (int i = 0; i < emptyLinesToAdd; i++) - { - lines.Add(Environment.NewLine); - } - emptyLinesToAdd = 0; - } lines.AddRange(equalLines); break; default: