Skip to content

Diff algorithm detects two consecutive added lines as two changes (instead of one) #119051

@bersbersbers

Description

@bersbersbers
  • VS Code Version: 1.54.3
  • OS Version: Windows 10, SSH to Linux

Steps to Reproduce:

  1. bug1.txt:
1


2

  1. bug2.txt:
1

1.5


2

3

  1. Compare selected

Result:
image

This diff is not wrong, but it's not minimal. The first two changes could be merged into one, just like diff does it:

> diff bug1.txt bug2.txt 
2a3,4
> 1.5
> 
4a7,8
> 
> 3

Interestingly, removing the final line break from bug2.txt prevents the issue:
image

Does this issue occur when all extensions are disabled?: Yes

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugdiff-editorDiff editor issuesinsiders-releasedPatch has been released in VS Code InsidersverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions