diffplex
diffplex copied to clipboard
spurious blank lines at end
In the output from the program below, the line with the "" and the blank line after it should not be there:
Changes: 2
"a"
x "b"
√ "x"
"c"
""
––––––––––
open System.Text
open DiffPlex.DiffBuilder
open DiffPlex.DiffBuilder.Model
let prefix lineType =
match lineType with
| ChangeType.Unchanged -> " "
| ChangeType.Inserted -> "√ "
| ChangeType.Deleted -> "x "
| ChangeType.Modified -> "≠ "
| ChangeType.Imaginary -> "i "
| _ -> failwith "Unknown line type in prefix"
let tallyChange lineType =
match lineType with
| ChangeType.Unchanged -> 0
| ChangeType.Inserted -> 1
| ChangeType.Deleted -> 1
| ChangeType.Modified -> 1
| ChangeType.Imaginary -> 0
| _ -> failwith "Unknown line type in noteChanged"
let show (diff: DiffPaneModel) =
let lines = diff.Lines
let sb = StringBuilder()
for line in lines do
sb.Append((prefix line.Type) + "\"" + line.Text + "\"" + "\n") |> ignore
let n =
diff.Lines
|> Seq.map (fun line -> (tallyChange line.Type))
|> Seq.sum
printfn "Changes: %d" n
printfn "%s" (sb.ToString())
printfn "––––––––––"
let test() =
let expected = "a\nb\nc\n"
let actual = "a\nx\nc\n"
let diff = InlineDiffBuilder.Diff(expected, actual, false)
show diff
[<EntryPoint>]
let main argv =
test()
0
It looks like it is working correct to me when I run it. It detects 5 lines (since the new line is at the end, creates another line) And it marks them correctly here
With this output
suggest we close this. unless a failing test (as a PullRequest) can be provided