oderwat / vscode-indent-rainbow

Extension which shows indentation with a faint rainbow colored background to make them more readable
MIT License
409 stars 55 forks source link

Mistakenly considering multi line code indentation as error #37

Closed vasselai closed 5 years ago

vasselai commented 5 years ago

Firstly, I have to say that this is a really great extension. Thanks for it! The only minor issue I have with it is that whenever I have to break long lines of code into a multi-line code (e.g. in Python, using the \ character), the extension detects such indentation as if it was an error:

image

Is there currently a way to circumvent such an issue, even if it requires minor alterations in the source code itself? If not, here's a quick thinking I had on this issue.

Obviously, the fully fledged solution to this would require individual code for each supported programming language (e.g. do not consider error if suspicious indentation appear in lines whose above line did not end with a ; in languages that require semicolons, or do not consider error if suspicious indentation appear in a line whose above line ended with a \ in Python).

But perhaps there is a less troublesome approach. You could give the user the ability to specify, for each desired language, an ending character and whether it closes a code statement (like ; in C++) or keeps a code statement open (like \ in Python). Then generically, the extension would just use that to check whether a line should be marked for error. Of course, that would still not handle languages like R, which do not require a special character neither to close code statements nor to keep them open, but it would cover a lot of ground.

oderwat commented 5 years ago

I tend to suggest to disable error lines in indent-rainbow and keep this functionality to language support packages / lint tools. I came to the conclusion that having this feature was an error in the first place.

vasselai commented 5 years ago

I think the feature is useful actually, but I do understand that you might think that having it was out of scope for your extension (since it's about indentation). Thanks anyways, I'll keep the feature disabled indeed and will try to get the error flagging in another way.