atom / language-javascript

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

Syntax Highlight Faults with `/**/` in Javascript source. #659

Closed l-cornelius-dol closed 5 years ago

l-cornelius-dol commented 5 years ago

Prerequisites

Description

Syntax highlighting fails to correctly highlight the rest of the line when an empty multiline comment, that is /**/, is encountered. I've noticed this in Javascript source, though it does not seem to happen in Java source files -- it's likely to be specific to Javascript and others, but not all.

Sometimes the highlighting for the rest of the file is also confused as well.

Steps to Reproduce

  1. Open a JS file.
  2. Insert an empty comment at the beginning of a non-blank line.

Expected behavior:

Correct syntax highlighting.

Actual behavior:

Some or all elements are highlighted using the styles for a comment, depending on the exact theme. In my minimalist theme it tends to be the entire line, but in the default safe-mode theme it tends to be only program identifiers and punctuation, but not keywords and constants.

Reproduces how often:

100% for the same line. About 50% for the rest of the file being affected, unpredictably.

Versions

Atom : 1.40.1 Electron: 3.1.10 Chrome : 66.0.3359.181 Node : 10.2.0

Windows 10 1903 18362.295.

Additional Information

Expected:

image

With empty comments:

image

Sometimes the rest of the file, sometimes not:

image

image

rsese commented 5 years ago

Thanks @lawrence-dol! Can you share a minimal example that we can copy/paste for testing?

l-cornelius-dol commented 5 years ago

This file, saved as TestComment.js works for me:

/**/function myFunction=function() {
    let one=1;
    one+=one;
    console.log("One","is not",one);
    };

I can replicate with any JS file, just by inserting an empty comment at the start of any line. Very occasionally, it won't happen, but then doing a CTL+SHF+F5 to force reload will cause the problem.

Note that it's not always to the end of the file either, on some larger files it just mysteriously begins working again on some random line. So to the end of the current line is most common, but sometimes for some number of following lines as well.

Is there an easy way to install a side-copy of Atom without disturbing my existing install so I can check for a problem with a vanilla install? I've already done safe-mode and it does replicate there.

A correlated behavior is that when I type the /* it does not immediately mark all following text as a comment up to the next */ as it does in other files (like Java). This, I think, provides a valuable clue as to what's happening.

Aerijo commented 5 years ago

This should be fixed on nightly, maybe beta but I’m not sure.

l-cornelius-dol commented 5 years ago

@Aerijo : Do you have a commit reference?

Aerijo commented 5 years ago

@lawrence-dol https://github.com/atom/atom/pull/19726 and https://github.com/atom/atom/pull/19738

rsese commented 5 years ago

oh lol that's the second time I've missed that one, thanks for catching it again @Aerijo 👍

l-cornelius-dol commented 5 years ago

Confirmed fixed on beta channel.