atom / language-javascript

JavaScript language package for Atom
Other
194 stars 236 forks source link

JavaScript syntax highlighting breaks then spreads when using innerHTML = `` #676

Closed MrSimmmons closed 3 years ago

MrSimmmons commented 4 years ago

Prerequisites

Description

Javascript syntax highlighting breaks by using back ticks with innerHTML which then spreads around the file if edited.

Steps to Reproduce

  1. Open atom and make a new file (You don't need to save it, but if you do save a .js file)
  2. Set the syntax to JavaScript if not already set
  3. Paste in this text
    class Testing {
    test(ele) {
        this.testingAgain(ele);
    }
    testingAgain(ele) {
        // ele.innerHTML = ``;
    }
    }
  4. First issue: Un-comment line 6. Notice how the syntax highlighting doesn't show up
  5. Second issue Cut all text from the file, then re paste it. Notice how none of the syntax highlighting is working.

Expected behavior:

All syntax highlight should work properly.

Actual behavior:

ele.innerHTML = ``;

Seems to break the syntax highlighting of its own line, but then if you try to edit lines around it, the broken syntax highlighting seems to spread through the rest of the file. If you open a JS file that already has this line in it, depending on the size of the file will depend on how many lines don't get the syntax highlighting. Its really quite weird.

Reproduces how often: Every time

Versions

macOS: 10.14.6

Atom: 1.48.0 Electron: 5.0.13 Chrome: 73.0.3683.121 Node: 12.0.0

Additional Information

Video of the syntax highlighting breaking: issue1

Video of the syntax highlighting issue spreading though the file: issue2

(Sorry for the low quality)

oparisblue commented 4 years ago

This issue also occurs in language-typescript files -- perhaps something further up the chain is causing it?

MrSimmmons commented 4 years ago

Few things I've found.

  1. If you start typing the HTML first and then type the .innerHTML part the highlighting works fine. fix1

  2. If you put a semicolon on the end of the line after you type some HTML in the back ticks it fixes the highlighting. But it you add it to the line before you type any HTML the highlighting stays broken. fix2

Kinda strange