Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(ruby) 'if defined?' is mis-highlighted as a def method #3025

Closed
TGWolf opened this issue Feb 27, 2021 · 1 comment
Closed

bug(ruby) 'if defined?' is mis-highlighted as a def method #3025

TGWolf opened this issue Feb 27, 2021 · 1 comment
Labels
bug good first issue Should be easier for first time contributors help welcome Could use help from community language

Comments

@TGWolf
Copy link

TGWolf commented Feb 27, 2021

When highlighting ruby code the matching is not correctly matching on 'if defined'

for example:

if defined?(key)

Instead of matching on the 2 keywords IF and DEFINED it instead matches on IF and DEF as keywords then matched INED as a title. The downside to this is the word defined is now in 2 different colours.

I think it is related to the use if def when defining a function in ruby and so it is matching def from the word defined and thinks you have a function called ined.

I am using version 10.5.0 of highlight.

Sample Code:

I am using sunburst.css (although this happens in others and I don't think the css is the issue)

#!/usr/bin/env ruby

require 'rubygems'
require 'gems'
require 'terminal-table'

if defined?(key)
    Gems.configure do |config|
        config.key = key
    end
else
    puts 'Using default gem creds'
end
@TGWolf TGWolf added bug help welcome Could use help from community language labels Feb 27, 2021
@joshgoebel
Copy link
Member

Confirm. Pretty sure our function detection should probably be def\s+ not def\s*.

@joshgoebel joshgoebel added the good first issue Should be easier for first time contributors label Feb 27, 2021
@joshgoebel joshgoebel changed the title Ruby highlighting is miss matching 'if defined' bug(ruby) 'if defined?' is mis-highlighted as a def method Feb 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue Should be easier for first time contributors help welcome Could use help from community language
Projects
None yet
Development

No branches or pull requests

2 participants