-
Notifications
You must be signed in to change notification settings - Fork 17.3k
Syntax highlighting is broken in many languages and it spreads around the file #21093
Description
Prerequisites
- Put an X between the brackets on this line if you have done all of the following:
- Reproduced the problem in Safe Mode: https://flight-manual.atom.io/hacking-atom/sections/debugging/#using-safe-mode
- Followed all applicable steps in the debugging guide: https://flight-manual.atom.io/hacking-atom/sections/debugging/
- Checked the FAQs on the message board for common solutions: https://discuss.atom.io/c/faq
- Checked that your issue isn't already filed: https://github.com/issues?utf8=✓&q=is%3Aissue+user%3Aatom
- Checked that there is not already an Atom package that provides the described functionality: https://atom.io/packages
Description
Syntax highlighting appears to be broken in a number of different languages. I had made this post in this repo earlier atom/language-javascript#676 about an issue in the JS language after updating to 1.47 https://github.com/atom/atom/releases/tag/v1.47.0 , but it got moved over to the JS language repo. I have gone through all the releases from 1.41 - 1.49 (current) and 1.47 is the first release where this issue is present (in both normal versions, and safe mode versions).
The effected languages that I have seen since 1.47 have been:
- JavaScript
- TypeScript
- HTML
- Ruby
- Rust (edited)
But who knows how many other languages are affected. This is defiantly not an isolated issue within a language as all 4 of these ones broke on release 1.47
The thing that makes this bug so strange (I go into detail a bit more on my previous issue above), is that if lines around the effected line are edited, the broken syntax highlighting spreads around the file. And if the code is copy-pasted into an empty file, or opened for the first time, multiple lines around the effected line all break.
Steps to Reproduce
- Open any version of atom past release 1.47
- Set the language to one of the 4 mentioned above
- Copy-paste the provided code for said language (In additional information section)
Expected behavior:
The syntax highlighting working normally all the time.
Actual behavior:
Starting at 1.47 onwards, when the syntax highlighting breaks, it makes the affected line go white. But when lines around the affected line are edited, the broken syntax highlighting seems to spread around the rest of the file.
Reproduces how often:
100% of the time after 1.47
Versions
1.46 Issue not present:
Atom : 1.46.0
Electron: 4.2.7
Chrome : 69.0.3497.128
Node : 10.11.0
apm 2.4.3
npm 6.2.0
node 10.2.1 x64
atom 1.46.0
python 2.7.10
git 2.21.1
1.47 Issue now present:
Atom : 1.47.0
Electron: 5.0.13
Chrome : 73.0.3683.121
Node : 12.0.0
apm 2.4.5
npm 6.2.0
node 10.2.1 x64
atom 1.47.0
python 2.7.10
git 2.21.1
1.49 Current as of time of writing:
Atom : 1.49.0
Electron: 5.0.13
Chrome : 73.0.3683.121
Node : 12.0.0
apm 2.5.0
npm 6.14.5
node 10.20.1 x64
atom 1.49.0
python 2.7.10
git 2.21.1
macOS 10.14.6
Additional Information
Code snippets for each language.
- Javascript & TypeScript:
let ele = document.getElementById("test");
ele.innerHTML = ``;
// Comment out the line above from the start, then select all, cut, then past. Highlighting now works
// Highlighting worked fine in 1.46The issue in this one is the backticks on line 3.
- HTML:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<script></script>
<!-- Comment out the line above from the start, then select all, cut, then past. Highlighting now works -->
<!-- Highlighting worked fine in 1.46 -->
<title></title>
</head>
</html>The issue in this one is the entire <script> tag
- Ruby:
def test(string)
s = StringScanner.new(string)
while !s.eos?
s.scan(/\(/)
s.scan(/\)/)
# Comment out lines 5 and 7, then select all, cut, then past. Highlighting now works
# Highlighting worked fine in 1.46
end
endThe issue in this one is the REGEX in the scan looking for opening and closing parentheses. Other REGEX's appear to work fine.
Edit: Added Rust: (#20884)
use crate::checks::{self, *};
pub fn foo() -> Result<(), Box<dyn error::Error>> {
let string = "foo";
Ok(())
}and (#20897)
#[x(y = z)]
struct W();
let x = "hello";Side note
I was able to find a workaround for the JavaScript and TypeScript languages which is at the bottom of my previous issue atom/language-javascript#676 . I haven't found a workaround for the HTML or Ruby languages though