Page MenuHomeSoftware Heritage

assets/highlightjs: Add synchronous version of lineNumberBlock
ClosedPublic

Authored by anlambert on Aug 13 2020, 6:45 PM.

Details

Summary

It enables to get a more readable code in diff-utils module by removing some
setTimeout instructions.

Diff Detail

Repository
rDWAPPS Web applications
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build is green

Patch application report for D3789 (id=13307)

Could not rebase; Attempt merge onto 0cb8a77860...

Updating 0cb8a778..a52a1309
Fast-forward
 cypress/integration/revision-diff.spec.js         | 318 ++++++++++-
 cypress/support/index.js                          |   2 +-
 swh/web/assets/src/bundles/revision/diff-utils.js | 656 +++++++++++++++-------
 swh/web/assets/src/utils/highlightjs.js           |   7 +-
 swh/web/browse/views/revision.py                  |  11 +-
 5 files changed, 783 insertions(+), 211 deletions(-)
Changes applied before test
commit a52a1309a9205e40b6d9c230e367a8556f035ce3
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Thu Aug 13 17:32:59 2020 +0200

    assets/highlightjs: Add synchronous version of lineNumberBlock
    
    It enables to get a more readable code in diff-utils module by removing some
    setTimeout instructions.

commit 3174b773c3dcb9537d4527d2da0d8b8ae3d4f815
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Wed Aug 5 16:05:39 2020 +0200

    assets/diff-utils: Add diff lines highlighting feature
    
    That new feature enables to highlight code fragments in a diff generated
    from the revision view by selecting a lines range with the mouse (click
    and Shift+click on line numbers).
    
    Both unified and split diff can be highlighted. For the split case,
    only lines from the left or right part can be highlighted but also lines
    spanning both.
    
    When a diff gets highlighted, an URL fragment will be added describing the
    highlighting state. When the revision view gets reloaded with it, the
    diff will be automatically computed, highlighted and displayed.
    
    Closes T2491

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/324/ for more details.

vlorentz added a subscriber: vlorentz.

I have to admit I don't really understand this setTimeout business, so I'm all for getting rid of it.

This revision is now accepted and ready to land.Aug 14 2020, 10:58 AM

I have to admit I don't really understand this setTimeout business, so I'm all for getting rid of it.

The lineNumbersBlock function schedules an asynchronous treatment to add line numbers in the DOM.
In the diff-utils module, we rely on those line numbers elements to prepare diff displays. So without
a synchronous version of the function, we need to postpone treatments using setTimeout to ensure line numbers elements
have been inserted in the DOM.

Build is green

Patch application report for D3789 (id=13396)

Rebasing onto 6be09894e3...

Current branch diff-target is up to date.
Changes applied before test
commit 5ce0cbd3e650fd838e5e9ce08d94e041404fa94a
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Tue Aug 18 15:29:42 2020 +0200

    assets/highlightjs: Add synchronous version of lineNumberBlock
    
    It enables to get a more readable code in diff-utils module by removing some
    setTimeout instructions.

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/327/ for more details.

Build is green

Patch application report for D3789 (id=13396)

Rebasing onto 6be09894e3...

Current branch diff-target is up to date.
Changes applied before test
commit 5ce0cbd3e650fd838e5e9ce08d94e041404fa94a
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Tue Aug 18 15:29:42 2020 +0200

    assets/highlightjs: Add synchronous version of lineNumberBlock
    
    It enables to get a more readable code in diff-utils module by removing some
    setTimeout instructions.

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/328/ for more details.