microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.35k stars 28.6k forks source link

Misalignment When Comparing Files with "File: Compare Active File With" Command #219874

Open thiagojramos opened 2 months ago

thiagojramos commented 2 months ago

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

VS Code Version/OS Version:

Version: 1.91.0-insider (system setup) Commit: aea213b7fcc7de5c24ad797ac1af209b159d451f Date: 2024-06-28T05:56:20.804Z Electron: 29.4.0 ElectronBuildId: 9728852 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 SO: Windows_NT x64 10.0.22631

Description:

When using the File: Compare Active File With command in Visual Studio Code to compare two open tabs, a rendering misalignment occurs between the tabs in the comparison view.

Steps to Reproduce:

  1. Open two text files in separate tabs.
  2. Ensure the first tab (in the tab order) is on the left and the second tab is on the right.
  3. Use the File: Compare Active File With command to compare the two tabs.

Expected Behavior:

The lines in the two files should be aligned correctly, with corresponding lines appearing on the same level across both tabs.

Actual Behavior:

Additional Information:

Notes:

Screenshots:

Issue

![Issue](https://github.com/microsoft/vscode/assets/45890502/7c1200bb-8ce2-49be-aab9-88a636182f7d)

After using the side-switch button

![After-using-the-side-switch-button](https://github.com/microsoft/vscode/assets/45890502/97b31c32-13e0-486a-9f01-9aff99c8ac09)

Line 1 moved from left to right

![Line-1-moved-from-left-to-right](https://github.com/microsoft/vscode/assets/45890502/dea2ee9e-d12c-4a0e-bb0b-6811b21714e8)

Attachments

Files used in the issue comparison:

hediet commented 1 month ago

This is a worst-case input to the current diff algorithm implementation, as there are many ways to align the "description" "anchors". It also took me a while to notice that the left side has one line that does not start with "description".

I think the misalignment of this one line could be improved: Bad vs good.

All in all, I wouldn't say this is a bug in the algorithm (as the diff is correct), but a feature request.