facelessuser/BracketHighlighter

Elixir language rule "close" regex bug

dognotdog opened this issue · 1 comments

Description

In Elixir, end is used to mark block bracket ends, but end: and end? are valid words that don't have the same meaning, as unlike in other languages the colon and question mark can be part of keywords / variable names. Current close regex is a simple match on end, and will also trigger on end: and friends.

Replacing

  "close": "\\b(end)\\b",

with

  "close": "\\b(end(?![:?]))\\b",

in the language rule definition seems to do the trick, and end: no longer causes confusion.

Support Info

  • ST ver.: 4107
  • Platform: osx
  • Arch: x64
  • Plugin ver.: 2.29.1
  • Install via PC: True
  • mdpopups ver.: 4.1.2
  • backrefs ver.: 5.0
  • markdown ver.: 3.2.2
  • pygments ver.: 2.1a0
  • jinja2 ver.: 2.10.1

Steps to Reproduce Issue

This piece of code causes BracketHighlighter not to be able to match the {}, though it is perfectly valid Elixir:

%{
  end: "this confuses BracketHighlighter"
}

Curiously, the open rule works (eg do: does not seem buggy), despite it also being a simple regex.

Elixir support was added by the community. Thanks for the info as I know absolutely nothing about Elixir 🙂.

Pull requests are also welcome.