Closed karlvr closed 3 years ago
@jdneo hmm, I think I might be out by one on this... it's reporting the error 1 character too far to the left...
@jdneo yeah, checked in the CheckStyle code and it is 0-based, so I'll add 1 to it.
Hi @karlvr
Sorry but maybe a very stupid question from me: How can I reproduce this problem?
@jdneo No problem! If your file has tab indentation, and is indented a couple of tabs, you'll see that before this patch the highlighted error in vs code is too far to the right (by 3 spaces for each tab if your tabs are 4 spaces)
I got your point. So how should the checkstyle configuration looks like for this case?
I'm using
<module name="RegexpSinglelineJava">
<property name="format" value="^\t* "/>
<property name="message" value="Indent must use tab characters"/>
<property name="ignoreComments" value="true"/>
</module>
<module name="Indentation">
<property name="basicOffset" value="2"/>
</module>
But seems it's not a correct way to reproduce
@jdneo Actually, it's for any check not just indentation checks. If you use tab indentation in your final, any check appears highlighted in the wrong spot. I used a FinalParameterCheck in my case.
Maybe it's because I have tabWidth set to 4 in my Checkstyle config, but I thought it defaulted to 8!
Yes I can see it use the final check:
This fixes the reported column of errors in VS Code in code that uses tab indentation.
CheckStyle has funny treatment of tabs. Its error.getColumn() returns a number that treats tabs as being however many spaces. Fortunately getolumnCharIndex() returns the correct value to send back to VS Code.