Skip to content

Commit a8065d9

Browse files
committed
fix: fix a bug in the variation diff endif parsing
1 parent 69b406f commit a8065d9

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

src/main/java/org/variantsync/diffdetective/variation/diff/parse/VariationDiffParser.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ private void parseLine(
329329
// Do not create a node for ENDIF, but update the line numbers of the closed if-chain
330330
// and remove that if-chain from the relevant stacks.
331331
diffType.forAllTimesOfExistence(beforeStack, afterStack, stack ->
332-
popIfChain(stack, fromLine, line, diffType)
332+
popIfChain(stack, fromLine, line)
333333
);
334334
} else if (options.collapseMultipleCodeLines()
335335
&& annotation.type() == AnnotationType.None
@@ -369,8 +369,7 @@ private void parseLine(
369369
private void popIfChain(
370370
Stack<DiffNode<DiffLinesLabel>> stack,
371371
DiffLineNumber elseLineNumber,
372-
LogicalLine line,
373-
DiffType diffType
372+
LogicalLine line
374373
) throws DiffParseException {
375374
DiffLineNumber previousLineNumber = elseLineNumber;
376375
do {
@@ -382,14 +381,7 @@ private void popIfChain(
382381
for (int i = 0; i < line.getLines().size(); i++) {
383382
list.add(line.getLines().get(i).content());
384383
}
385-
if (diffType.existsBefore() && diffType.existsAfter()) {
386-
annotation.setEndIf(list, Time.BEFORE);
387-
annotation.setEndIf(list, Time.AFTER);
388-
} else if (diffType.existsBefore()) {
389-
annotation.setEndIf(list, Time.BEFORE);
390-
} else {
391-
annotation.setEndIf(list, Time.AFTER);
392-
}
384+
annotation.setEndIf(list, stack == beforeStack ? Time.BEFORE : Time.AFTER);
393385
}
394386

395387
// Set the line number of now closed annotations to the beginning of the
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#ifndef A
2+
code
3+
-#endif
4+
5+
-#ifndef A
6+
code
7+
#endif // A

0 commit comments

Comments
 (0)