pangloss/vim-javascript

Function declaration's closing bracket highlighted as error

andresrodco opened this issue · 1 comments

When any but the last destructuring key is surrounded by quotes, the error occurs:
Screen Shot 2020-12-24 at 10 40 52

When any but the last destructuring key is NOT surrounded by quotes, the highlight is ok:
Screen Shot 2020-12-24 at 10 42 31

I've managed to research a little bit the issue and this is what I found:

  • This happens in a .js file.
  • This happens to the closing bracket of a function declaration. Doesn't matter if it's exported or not.
  • This happens only when inside that function there's a nested object destructuring statement AND any of the keys but the last one is surrounded by quotes, either single, double, or backticks (see images above).
  • The result of SyntaxAttr for that closing bracket is group: jsParensError->Error guifg=255(255) guibg=203(203), which is declared in the syntax/javascript.vim file.
  • I'm using Vim Polyglot with no additional configuration for javascript files.

I think I found a fix.

We need to create a new region called jsDestructuringPropertyString and include it in the contains attribute of the jsDestructuringBlock region.

The new jsDestructuringPropertyString should be:

syntax region  jsDestructuringPropertyString    contained matchgroup=jsObjectKeyString     start=+\z(["']\)+  skip=+\\\%(\z1\|$\)+  end=+\z1\|$+  contains=jsSpecial skipwhite skipempty nextgroup=jsObjectValue

I'll see if I can create a PR for that.