Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Incorrect CHANGE? #114

Closed
Closed
@cosmoter

Description

@cosmoter

Let's assume we had a file with such a content:
"
A
B
C
D
E
"
We changed the file to:
"
a
C

E
"

Patch =
ChangeDelta, position=0, lines = [A, B] to [a]
UnchangedDelta, position=2, lines = [C] to [C]
ChangeDelta, position=3, lines = [D] to []
UnchangedDelta, position=4, lines = [E] to [E]

DiffRows =
CHANGE, "A" -> "a"
CHANGE, "B" -> ""
CHANGE, "C" -> "C"
CHANGE, "D" -> ""
CHANGE, "E" -> "E"

So DiffRows mixed two absolutely different situations:
CHANGE, "B" -> "" - that was a part of change but has no correspondence in the new file (maybe only "no line")
CHANGE, "D" -> "" - that was actually changed to the empty line

And we cannot distinguish what line in the new file is for E now.
3, 4, or 5?

I offer to set not CHANGE but DELETE for the situation "B" -> "" (or insert vice versa).
Yes it was a part of the change section but in terms of lines it is a deletion. There was a line and there is no line now.
The expected result is:
CHANGE, "A" -> "a"
DELETE, "B" -> ""
CHANGE, "C" -> "C"
CHANGE, "D" -> ""
CHANGE, "E" -> "E"

Another possible solution is to use null for "B" -> "" that can help distinguish two options. But we need to work with null after that.
CHANGE, "A" -> "a"
CHANGE, "B" -> null
CHANGE, "C" -> "C"
CHANGE, "D" -> ""
CHANGE, "E" -> "E"

The error exists in the last version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions