Skip to content

broken indenting/bracket jump when some RegExp passed as fn arg #149

@jaawerth

Description

@jaawerth

Hi there! Overall I love the plugin, but I've encountered a bug a few times that I wanted to file:

When certain RegExp literals (from what I can tell, anything ending in .$, '*$', '+$', and any other non-alphanumeric character I've tried followed by $) are passed directly into functions, the following line(s) are auto-indented. You can set them back, but triggering auto-indent in anyway puts it back where it was. It seems like yajs isn't recognizing the close paren at the end of the function invocation, because it also skips the ) when using % to jump between start and end.

I've run into this a few times, but in this case I boiled down the most recent regex to cause it to anything ending in .$.

Test Case

function foo() {}
foo(/whatever.$/); // hitting % on the open paren will jump to the next close paren it sees in file
  // this line will auto-indent

Assigning the RegExp to a variable first and passing that in won't cause the indent

function foo(){}
const reg = /whatever.$/;
// no indent here
foo(reg)

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions