codemirror / dev

Development repository for the CodeMirror editor project
https://codemirror.net/
Other
5.94k stars 377 forks source link

Incorrect view height in merge view with two same ~100k line documents #1408

Closed nooblyf closed 3 months ago

nooblyf commented 4 months ago

Describe the issue

Two same text contents with ~100k lines are having different heights in merge view

Link was too large so i'll write down the steps to reproduce:

  1. Set view a's text content to be ~100k lines
  2. Make view b editable and set it's content as empty
  3. Hit run, then copy a's content and paste into view b
  4. Both a and b have same content with same line numbers but have different heights

https://github.com/user-attachments/assets/90682f90-a872-465a-abee-5c32a1ce83e3

Browser and platform

chrome, macOS

Reproduction link

https://codemirror.net/try/?example=Merge%20View

nooblyf commented 4 months ago

Update, i was able to create a reproduction here: https://codemirror.net/try/?c=aW1wb3J0IHtNZXJnZVZpZXd9IGZyb20gIkBjb2RlbWlycm9yL21lcmdlIgppbXBvcnQge0VkaXRvclZpZXcsIGJhc2ljU2V0dXB9IGZyb20gImNvZGVtaXJyb3IiCmltcG9ydCB7RWRpdG9yU3RhdGV9IGZyb20gIkBjb2RlbWlycm9yL3N0YXRlIgoKY29uc3QgZG9jID0gU3RyaW5nKGBvbmUKdHdvCnRocmVlCmZvdXIKZml2ZWApLnJlcGVhdCg0OV83NDEpOwoKbGV0IHZpZXcgPSBuZXcgTWVyZ2VWaWV3KHsKICBhOiB7CiAgICBkb2MsCiAgICBleHRlbnNpb25zOiBiYXNpY1NldHVwCiAgfSwKICBiOiB7CiAgICBkb2M6ICIiLAogICAgZXh0ZW5zaW9uczogWwogICAgICBiYXNpY1NldHVwLAogICAgXQogIH0sCiAgcGFyZW50OiBkb2N1bWVudC5ib2R5Cn0pCg==

Weird thing is that if i change the repeat from 49_741 to 49_740 it works fine

marijnh commented 3 months ago

I think I found a workable solution to this. Please try with attached patch (@codemirror/merge 6.6.6, ominously)

nooblyf commented 3 months ago

It's fixed in Safari but for Chrome and Firefox it's still same

marijnh commented 3 months ago

Oh, you're right, that wasn't correct, it just randomly happened to work when I tested. Attached patch should clean it up.

nooblyf commented 3 months ago

Thanks man! Works on all three browsers 🙌🏽