elixir-lsp / elixir-lsp/vscode-elixir-ls

Whole module is highlighted on a local do..end mismatch

Open
#451 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
599
Forks
108
PR merge metrics
No merged PRs in 30d

Description

This is in VSCode with the ElixirLS extension version 0.26.4, under Elixir 1.17.3 / OTP 27.

There is a distracting behavior of an error highlighting I was trying to figure out and so far couldn't. On pretty much any non-matching `do..end` block the whole module gets highlighted with squiggles which is quite distracting. As during editing it is not rare to have non-matching `do..end` blocks, this happens a lot.

I couldn't find a way to disable this behavior, please point me at it if there is one. For me the desired behavior on non-matching blocks would be to only have the opening bit of the deepest affected block selected, and not the whole of it, and of course not anything outside.

---
### Details

What seems notable, the information about the locality of the error is present in the error message and maybe can be used to limit the error selection to the relevant area.

Here is an example of a non-matching square bracket, the effect is reasonably local squiggles, although could be made better by only highlighting the unmatched opening bracket. Maybe it could also rely on indentation to not highlight anything below the expected location, but this is debatable.
Image

Here is a non-matching curly bracket, similar behavior, still acceptable:
Image

And here is a non-matching `do..end` block where the whole module gets highlighted which is not only distracting, but also useless:
Image

Notably, if we look at the error details, there is a hint on the actual locality of the non-matched `do`, which happens to be at line 9:
Image

In a situation with a deeper nested `do..end` the behavior is similarly undesirable, but in this case the locality is not detected correctly, as the erroneous line is now 23, and not 9. Even then, limiting the selection to the block starting at line 9 would be helpful.
Image

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.