yats.vim icon indicating copy to clipboard operation
yats.vim copied to clipboard

tsx syntax highlighting and folding broken when function default arguments are objects

Open felamaslen opened this issue 4 years ago • 0 comments

I reproduced this in neovim v0.4.3.

Steps to reproduce:

  1. Create basic init.vim:
cat > init.vim <<EOF
call plug#begin()
Plug 'HerringtonDarkholme/yats.vim'
call plug#end()
set foldmethod=syntax
EOF
  1. Create test file:
cat > break-yats.tsx <<EOF
describe("this breaks", () => {
  describe.each`
    field    | value    | fieldValue
    ${"foo"} | ${"bar"} | ${undefined}
    ${"baz"} | ${"bak"} | ${{ some: "prop" }}
  `(
    "when making complex default parameters around a nested test",
    ({ field, value, fieldValue = { [field]: testValue } }) => {
      it("breaks syntax highlighting in this test", () => {
        expect(something).toStrictEqual({
          boz: value,
          ...fieldValue,
        });
      });
    }
  );

  describe("breakage", () => {
    it("breaks syntax highlighting here", () => {
      expect(syntaxHighlighting).toBeBroken();
    });

    it("breaks syntax folding here", () => {
      expect(syntaxFolding).toBeBroken();
    });
  });
});
EOF
  1. nvim -u init.vim break-yats.tsx

Observe that the folding is as follows:

image

Also observe that the syntax highlighting is as follows:

image

Expected behaviour:

The folding should look like this:

image

Also the syntax highlighting should be as follows:

image

felamaslen avatar May 15 '20 21:05 felamaslen