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

Syntax highlight breaks on Kernel.` method

Open viralpraxis opened this issue 1 year ago • 1 comments

Description

The following code breaks syntax highlighting feature:

# frozen_string_literal: true

def do_test
  _h = { a: 1, b: 2 }

  Kernel.`"cat /bin/false"

  { a: 1, b: 2 }
end

Screenshot from 2024-03-07 04-15-48

Prism's AST seems to be OK:

$ bin/parse -e 'Kernel.`"cat /bin/false"'
@ ProgramNode (location: (1,0)-(1,24))
├── locals: []
└── statements:
    @ StatementsNode (location: (1,0)-(1,24))
    └── body: (length: 1)
        └── @ CallNode (location: (1,0)-(1,24))
            ├── flags: ∅
            ├── receiver:
            │   @ ConstantReadNode (location: (1,0)-(1,6))
            │   └── name: :Kernel
            ├── call_operator_loc: (1,6)-(1,7) = "."
            ├── name: :`
            ├── message_loc: (1,7)-(1,8) = "`"
            ├── opening_loc: ∅
            ├── arguments:
            │   @ ArgumentsNode (location: (1,8)-(1,24))
            │   ├── flags: ∅
            │   └── arguments: (length: 1)
            │       └── @ StringNode (location: (1,8)-(1,24))
            │           ├── flags: ∅
            │           ├── opening_loc: (1,8)-(1,9) = "\""
            │           ├── content_loc: (1,9)-(1,23) = "cat /bin/false"
            │           ├── closing_loc: (1,23)-(1,24) = "\""
            │           └── unescaped: "cat /bin/false"
            ├── closing_loc: ∅
            └── block: ∅

latest VScode VScode ruby-lsp plugin v0.5.12 Gem ruby-lsp 0.14.4

VSCode show-syntax-tree result:

show-syntrax-tree.txt

viralpraxis avatar Mar 07 '24 01:03 viralpraxis

Thank you for the bug report! The issue is certainly in the grammar file. I believe the lone backtick is throwing off the regex rules.

vinistock avatar Mar 07 '24 14:03 vinistock