Word brackets should be detected with word boundaries
Problem
When there are single lined do...end block inside Elixir code, bracket-lens cannot parse brackets correctly.
Examples
In the valid Elixir code below, brackets aren't correctly detected:

What is happening
def zip is judged to be inside def bar(null)'s do block.
Configuration
"[elixir]": {
"bracketLens.languageConfiguration": {
"ignoreCase": false,
"comments": {
"block": [
{
"opening": "@moduledoc \"\"\"",
"closing": "\"\"\""
},
{
"opening": "@doc \"\"\"",
"closing": "\"\"\""
},
],
"line": [
"#"
]
},
"brackets": {
"symbol": [
{
"opening": "(",
"closing": ")",
"headerMode": "smart",
"inters": []
},
{
"opening": "[",
"closing": "]",
"headerMode": "smart",
"inters": []
},
{
"opening": "{",
"closing": "}",
"headerMode": "smart",
"inters": []
},
],
"word": [
{
"opening": "do",
"closing": "end",
"headerMode": "smart",
"inters": []
}
{
"opening": "fn",
"closing": "end",
"headerMode": "smart",
"inters": []
}
]
},
"strings": {
"inline": [
{
"opening": "\"",
"closing": "\"",
"escape": "\\\""
},
{
"opening": "'",
"closing": "'",
"escape": "\\'"
}
],
"multiline": [
{
"opening": "\"\"\"",
"closing": "\"\"\"",
"escape": "\\\"\\\"\\\""
}
]
}
}
},
Thoughts
In Elixir, do...end blocks are syntax sugar of [do: term] keyword lists, which could be written without brackets.
if some do
true
else
false
end
if some, do: true, else: false
if(some, [do: true, else: false])
if(some, [{:do, true}, {:else, false}])
These are all the same.
If my settings are not wrong, maybe we need a "ignore" option to ignore do: s.
{
"opening": "do",
"ignore": ["do:", ":do"],
}
I rethought about this...
Maybe we can just make the opening closing options to match strictly by the word boundary, like the \b anchor in regexp.
# given settings as `"word": [ { "opening": "do" } ]`
def foo do # <- matches
...
end
def foo, do: ... # <- does not match, because `do:` is not `do` when regexp is /\bdo\b/
This should not be enabled on symbol brackets, because then this kind of troubles occur:
public static main(int i; //<- will not match
return null;
)
But when using word brackets, I don't think anyone (any language) wants dos and ends to work without a word boundary.
First, thank you for suggestions!
But I'm not sure about this.
This should not be enabled on symbol brackets, because then this kind of troubles occur:
public static main(int i; //<- will not match return null; )
Isn't it the behavior due to the bracketLens.minBracketScopeLines option?
Ah no, I meant that if you force to match symbol brackets by word boundaries too, like /\b\(\b/, then that opening bracket in the example above won't match (which should be detected).
日本語OKだったことに気づいたので日本語で書きます(説明難しかったので) symbol bracketの場合に単語境界を必須にしていると、上の例のような変な改行位置ではあるが有効なコードである場合に正しくパースできなくなってしまう気がしまうので、word bracketだけ単語境界を見るようにしてほしいです、という話でした!