Closed jeff-hykin closed 3 years ago
Same problem with the exact same versions of Atom, Electron, Chrome, and Node (Arch Linux x64)
With language-ruby
With ruby on rails
Same here
I've narrowed this down to regex parsing in my case.
With a dummy variable assigned as a string, we've got no problem:
Add a regex with a special character class and that line goes white:
Save, close, and reopen, and the whole file is white:
Same issue does not occur with a simpler regex (plain d
character instead of \d
char class)
Or with a regular character after the \d
:
Seems like my observations may be consistent with the use of \$
above.
Interpolation also appears to affect this, as in the /#{known_errors.join("|")}/
in OP's example
Text in my example for ease of copy-paste:
def message(service, event)
test = /\d/
text = ":goodnews: *Service Inquiry Status Update*\n" \
"Media File: <#{media_file_url(service.media_file)}|#{service.media_file&.display_name}>\n" \
"#{service.type} <#{service_url(service)}|#{service.id}>\n" \
"Event: #{event}"
return prod? ? text : dev_tag + text
end
And I can confirm that the minimal example
def foo
/\d/
end
or even just
/\d/
triggers the issue.
@jeff-hykin would it be appropriate to edit the title of this issue to something like "regex literals with some special characters break syntax highlighting" to get some more focused eyes on this issue?
Thanks for actually making progress on this @ozydingo I think I've seen an issue posted on Atom/Atom that describes this problem for multiple languages, so this should maybe be closed in favor of that one. However I can't seem to find that issue now.
It's probably the same issue, but I pause to close this since the syntax highlighting is not broken using language-ruby-on-rails
, only language-ruby
. If it's core to atom, I'm not sure why we would see that difference, but I could imagine up some scenarios sure. Still, I'd personally vote to leave this issue open given the slight possibility that this is in fact a language-ruby
-specific issue.
It is a Tree-sitter bug; language-ruby-on-rails
is a TextMate grammar.
I don't know if it's the same root cause, but Tree-sitter is known to have broken highlighting for a few languages.
Prerequisites
Description
The discoloration has some pretty strange behavior, it seems like a rendering problem instead of a parsing problem. It's a pretty big bug but I couldn't find a pre-existing issue for it.
Top of file is discolored, but (see next)
coloration is resumed a bit further down.
Steps to Reproduce
atom --safe
this gets its value from the info.yaml file
$info = Info.new # load the info.yaml
$paths = $info.paths path_to_urls = $paths['all_urls'] PARAMETERS = $info['parameters']
def force_explicit_pathing(path) if FS.absolute_path?(path) File.join("/",path) else File.join("./",path) end end
def relative_path(from:nil, to:nil) Pathname.new(to).relative_path_from(Pathname.new(from)) end
def get_video_ids_for(url) return Hash[ Nokogiri::HTML.parse(open(url).read).css('*').map{ |each| each['href'] =~ /^\/watch\?v=([^\&]+)/ && $1 }.compact.collect{ |item| [item, {}] } ] end
def get_full_url(video_id) "https://www.youtube.com/watch?v=" + video_id end
def get_metadata_for(url) result =
youtube-dl -j '#{url}' 2>&1
known_errors = [ "ERROR: This video has been removed for violating YouTube's Community Guidelines", "ERROR: This live stream recording is not available", "ERROR: This video is unavailable", ] if result =~ /#{known_errors.join("|")}/ return { unavailable: true, } end all_data = JSON.load(result) return {title: all_data["title"],
end
class Numeric def percent return self/100.0 end end
def confidence_interval(total_num_of_trys, num_of_successes, confidence:0.95) return 0 if total_num_of_trys == 0
end
language-ruby: 0.72.23 Atom : 1.48.0 Electron: 5.0.13 Chrome : 73.0.3683.121 Node : 12.0.0