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

Syntax highlighting fails when using methods called named after ruby keywords

Open Max-Leopold opened this issue 3 years ago • 0 comments

Defining or using methods named after ruby keywords which use the <keyword> [...] end syntax (like while [...] end or def xxx [...] end) breaks the syntax highlighting.

Some examples:

Using methods named end

image
foo = Range.new(1, 10)
foo.end


def bar
  bar = Range.new(1, 10)
  bar.end
end

def end
  puts "Hello World"
end

self.end

Using methods named def

This code snippet is invalid ruby code, I just wanted to show that the syntax highlighting matches thinks the self.def and the last end belong together.

image
def def
  puts "foo"
end

self.def

def bar
  puts "bar"
end

end

Using methods named while

image
def while

end

a = 1
while a < 2
  puts a
  a += 1
end

Using classes named End

image
class End
  def foo
    puts "foo"
  end
end

End.new.foo

Max-Leopold avatar Sep 17 '22 09:09 Max-Leopold