language-ruby icon indicating copy to clipboard operation
language-ruby copied to clipboard

Losses syntax highlighting and text becomes grey when adding erb tags in Ruby

Open anihakutin opened this issue 6 years ago • 24 comments

Prerequisites

  • [X] 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

Code after inserted erb text becomes grey and losses syntax highlighting. Closing the file and then reopening it fixes the issue. I did see this mentioned in issue #18342 but that was closed and the syntax highlighting doesn't seem to be fixed. Safe mode does not solve this problem.

Steps to Reproduce

  1. Create .erb file with html
  2. Add erb tag to html element
  3. Text will lose syntax highlighting (see screen recording below)

Edit by @rsese to add more detailed repro steps

  1. Create and save a .erb file with this content:
<h1>Update Owner</h1>

<form method="post">
  <input action="/owners/" type="hidden" id="hidden" name="_method" value="patch">

  <label for="">Name: </label>
</form>
  1. Start typing <%[email protected]%> after the "/owners/" in the <input> tag.

**Interesting note: If I add the "=" after i close the tag it highlights and formats correctly, see 2nd screen recording.

Expected behavior: [What you expect to happen] Highlighter should highlight syntax correctly

Actual behavior: [What actually happens]

After typing the > in <%[email protected]%>, the rest of the content loses highlighting (as mentioned above, closing and reopening the file seems to clear things up).

See screen recording: giphy 1

Screenshot: screen shot 2019-02-09 at 11 40 54 pm

When adding the "=" after closing the tag: giphy 2

Reproduces how often: [What percentage of the time does it reproduce?] Everytime.

Versions

Atom : 1.34.0 Electron: 2.0.16 Chrome : 61.0.3163.100 Node : 8.9.3 MacOS Mojave 10.14.2 (18C54)

anihakutin avatar Feb 10 '19 04:02 anihakutin

Thanks for the report, reproduce in 1.34.0 with macOS 10.12.6.

rsese avatar Feb 13 '19 21:02 rsese

I can still reproduce this in Atom 1.39.0

SeaCDragon avatar Jul 28 '19 02:07 SeaCDragon

Still here in 1.40.1

amingilani avatar Sep 19 '19 14:09 amingilani

I can reproduce in Atom 1.40.1, with Ubuntu 18.04.3 LTS Downgraded atom to 1.33.1, only way to solve this problem atm.

aurangzaib-danial avatar Oct 16 '19 18:10 aurangzaib-danial

Atom 1.40.1 / MacOS 10.14.6 still experiencing the same issue with ERB.

dcchambers avatar Dec 13 '19 19:12 dcchambers

Tested today on Atom 1.41.1 and 1.42 this is no longer happening. Consider this resolved?

dcchambers avatar Jan 08 '20 19:01 dcchambers

unfortunate no we cant. Even on 1.43 this still happens fairly often. I am on Mac

SeaCDragon avatar Jan 21 '20 05:01 SeaCDragon

Same here. Found this while hoping there was a fix.

ryanwith avatar Mar 15 '20 19:03 ryanwith

still a problem in Atom 1.45

GuzmanHrz avatar Apr 07 '20 17:04 GuzmanHrz

I've have experienced this issue, and now (1.47) I've got a new one that I think might be related. I can open some erb files that have full color, then open another erb file with no color. With the problem described above, closing and reopening the file would fix it. With this new problem there is no highlighting from open.

Also, adding code above the gray lines seems to do full highlighting, while adding below only highlights the <% %>

I also have the (non-treesitter?) HTML (Rails) and HTML (Ruby - ERB) grammars, and switching to one of those gives full highlighting.

2020-06-04 14 13 41

hayesr avatar Jun 04 '20 18:06 hayesr

Tinkering further, I believe the following is the problem:

<% if @thing %>
    <script></script>
<% end %>

That code will cause the issue in other files, BUT the following does not cause the problem:

<% if @thing %>
    <script>
<% end %>

(no close to the script tag)

hayesr avatar Jun 04 '20 18:06 hayesr

This is occuring on .rb files as well.

dougc84 avatar Jun 07 '20 09:06 dougc84

Having the same problem. It seems as soon as I enter a , everything goes grey, with occasional, random highlighting. Frustrating because I'm a newbie and the highlighting was very helpful (when it was working).

shannon-bart avatar Jun 10 '20 19:06 shannon-bart

I am also experiencing this issue on 1.48.

AlbertoReg avatar Jun 22 '20 23:06 AlbertoReg

Still 1.48, and still experiencing this after adding in a .html document.

GrinninBarrett avatar Jul 10 '20 18:07 GrinninBarrett

Same here 1.48.0

erez avatar Jul 14 '20 14:07 erez

Still got this issue in 1.5

MatthewKennedy avatar Aug 15 '20 21:08 MatthewKennedy

Can confirm random greyed out lines and/or script tags v1.5.0 pretty annoying

samyH avatar Sep 16 '20 08:09 samyH

I gave up on atom and moved to Sublime Text 4, the code highlighting is instant.

I tried VSCode but that was slow at loading the syntax and the colours were inconstiant.

Screenshot 2020-09-16 at 14 37 42

MatthewKennedy avatar Sep 16 '20 13:09 MatthewKennedy

Ah sublime text is up to v4, might have to check it out - came from sublime to atom because there was a nice package called html preview which updates the page on the fly and runs inside atom

samyH avatar Sep 16 '20 15:09 samyH

I'm also still seeing this, in Atom 1.52.0 on MacOS 10.15.7

Was this bug possibly introduced with #240?

BARK-PHOLLAND avatar Nov 02 '20 21:11 BARK-PHOLLAND

Any progress of this? Getting a LOT of issues with ERB files... I mean, A LOT! Ruby on Rails and ERB files are my main projects, is so annoying that I'm using VSCode.

BTW, I noticed that if I narrow the width of the editor, the syntax works again in some points. I don't know if it's because part of the code is hidden or if the width has something to do with it.

ezgif com-video-to-gif

brunnopleffken avatar Dec 17 '20 17:12 brunnopleffken

Any progress of this? Getting a LOT of issues with ERB files... I mean, A LOT! Ruby on Rails and ERB files are my main projects, is so annoying that I'm using VSCode.

BTW, I noticed that if I narrow the width of the editor, the syntax works again in some points. I don't know if it's because part of the code is hidden or if the width has something to do with it.

ezgif com-video-to-gif

Just install Sublime Text save yourself the headache

samyH avatar Dec 18 '20 09:12 samyH

Just install Sublime Text save yourself the headache

I'm using VS Code as main editor for Ruby projects. It's a lot of headache for a simple syntax highlight...

TBH, the Atom highlight is very good, it marks the right words even with the name of functions outside the "dictionary". But the problem of colors deactivating is really annoying.

brunnopleffken avatar Dec 19 '20 12:12 brunnopleffken