Skip to content

frontend/highlighting: don't repeat token highlighting

Created by: rvantonder

This highlighting bug from #6441 started to bother me more and more and this is a fix. Example:

Screen Shot 2020-01-15 at 12 49 15 AM

I debugged this and found that extra selection-highlight nodes are sometimes added. While we check for repeat highlighting in along the one branch of this code, we don't do it for the other. This adds the check to the other branch.

Testing:

  • I added a test and checked that it fails as expected without this change. Without the change, this test will fail, and you'll see nested/repeated <span class=selection-highlight> when that shouldn't happen. The cell values are based off of the reported issue in #6441.
  • All existing tests pass.

Note:

There's probably a way to restructure this code so that we don't do the work of constructing the highlight or containerNode elements before this check, but since the other branch isn't exactly trying to avoid this either, I making a minimal change to get the desired functionality rather than restructuring this code.

Merge request reports

Loading