Overlapping openedBy/closedBy regions

Hello,

I have trouble understanding the nature of the openedBy and closedBy props.

Here is an example of a simple Lezer grammar:

@top Program {
  A[closedBy="B"] { "[" }
  "foo"
  X[closedBy="Y"] { "{" }
  "bar"
  Y[openedBy="X"] { "}" }
  "baz"
  B[openedBy="A"] { "]" }
}

The corresponding parser successfully parses [foo{bar}baz], and CodeMirror in its basic configuration successfully highlights the inner matching pairs of brackets. However, each bracket of the outer pair gets matched to its inner “counterpart”, and thus the highlighting breaks.

Is this a feature?

That was an off-by-one bug in the matching, in a rarely exercised code path. Patch below fixes it.

1 Like

Oh, sweet! Thanks a lot!