Repository: vscode
Issue: Misalignment When Comparing Files with "File: Compare Active File With" Command
Labels: feature-request,diff-editor

<!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ -->
<!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ -->
<!-- 🕮 Read our guide about submitting issues: https://github.com/microsoft/vscode/wiki/Submitting-Bugs-and-Suggestions -->
<!-- 🔎 Search existing issues to avoid creating duplicates. -->
<!-- 🧪 Test using the latest Insiders build to see if your issue has already been fixed: https://code.visualstudio.com/insiders/ -->
<!-- 💡 Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. -->
<!-- 🔧 Launch with `code --disable-extensions` to check. -->
Does this issue occur when all extensions are disabled?: Yes

<!-- 🪓 If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. -->
<!-- 📣 Issues caused by an extension need to be reported directly to the extension publisher. The 'Help > Report Issue' dialog can assist with this. -->

<details><summary>VS Code Version/OS Version:</summary>
<p>

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

</p>
</details> 

## 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:

- The second line of the left tab aligns with the fourth line of the right tab, regardless of the tab resizing (the part that divides the tabs).
- However, when swapping the sides of the compared tabs, the alignment is correct, with the second line of both tabs aligned.

## Additional Information:

- Both files are plain text, and the first six lines have the same indentation and line breaks (when one line is split into multiple lines).
- When the second line (empty) of the right tab is moved from left to right, it not only moves the line but also merges the content of the second line (which is empty in both) and the third line. It seems to consider the first, second, and third lines of the right tab as only the first line of the left tab, since the second line of the left tab is aligned with the fourth line of the right tab.

## Notes:

- The issue occurs even with all extensions disabled.

## Screenshots:

<details><summary>Issue</summary>
<p>

![Issue](https://github.com/microsoft/vscode/assets/45890502/7c1200bb-8ce2-49be-aab9-88a636182f7d)

</p>
</details> 

<details><summary>After using the side-switch button</summary>
<p>

![After-using-the-side-switch-button](https://github.com/microsoft/vscode/assets/45890502/97b31c32-13e0-486a-9f01-9aff99c8ac09)

</p>
</details> 

<details><summary>Line 1 moved from left to right</summary>
<p>

![Line-1-moved-from-left-to-right](https://github.com/microsoft/vscode/assets/45890502/dea2ee9e-d12c-4a0e-bb0b-6811b21714e8)

</p>
</details> 

## Attachments

Files used in the issue comparison: 

- [left_tab.txt](https://github.com/user-attachments/files/16087420/left_tab.txt)

- [right_tab.txt](https://github.com/user-attachments/files/16087436/right_tab.txt)