stable

Clone or download

Read-only

Synchronize scrolling with two diffs

Part of story #11667 display diff side by side How to test: - Browse a pullrequest - In the side-by-side diff, the scrolls are generally aligned. Scrolling on one side should scroll in the other. - Code that was added or deleted will have placeholder line widgets with equal size on the other view to keep the document height. Notes: - I just know the reviewer will find issues with the scrolling. Please take the following into consideration: - I looked at Gerrit's code [1] for inspiration for the scroll-synchronizer. Their code does complicated things including a binary search for matching unchanged lines to align them. It seems to adress a case with people throw-scrolling that would break scroll alignment. I did not try to adapt it. If this should be implemented, I recommend to do it in a dedicated commit. - Honestly, synchronizing scrolling with CodeMirror is much more complicated than I initially thought. Just take a look at the CodeMirror-maintained "merge" addon [2]. It seems that unless we invest a big amount of time and add lots of code, there will be some corner-cases with scroll synchronization. [1]: https://github.com/GerritCodeReview/gerrit/commit/7ba907963c8f52588a4f04947d30666b592030e9 [2]: https://codemirror.net/addon/merge/merge.js Change-Id: Id391242f8fd5867b7adf67b5dabcbf5b55e3de3d

Modified Files

Name
M plugins/pullrequest/www/scripts/src/app/app.spec.js +5 −3 Go to diff View file
A plugins/pullrequest/www/scripts/src/app/file-diff/diff-modes/side-by-side-data-builder.js +91 −0 Go to diff View file
A plugins/pullrequest/www/scripts/src/app/file-diff/diff-modes/side-by-side-data-builder.spec.js +136 −0 Go to diff View file
M plugins/pullrequest/www/scripts/src/app/file-diff/diff-modes/side-by-side-diff-component.js +38 −4 Go to diff View file
A plugins/pullrequest/www/scripts/src/app/file-diff/diff-modes/side-by-side-scroll-synchronizer.js +64 −0 Go to diff View file
A plugins/pullrequest/www/scripts/src/app/file-diff/diff-modes/side-by-side-scroll-synchronizer.spec.js +123 −0 Go to diff View file
A plugins/pullrequest/www/scripts/src/app/window-helper.js +26 −0 Go to diff View file
M plugins/pullrequest/www/themes/BurningParrot/css/includes/_file-diff.scss +5 −0 Go to diff View file