-
Notifications
You must be signed in to change notification settings - Fork 512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tab indentation breaks KDoc comments #850
Comments
Note: This obviously also triggers wrong warnings when linting, i.e. |
I was planning on changing the indentation tests to require a tab and space variant for all the fixtures which would have caught this. Thanks for trying out tabs! |
I can not reproduce the problem as the original code is not submitted. Also I would like to know what indent styling should be used. So based on the expected behaviour I have tried a number of different situations but still could not reproduce the misalignment of the KDoc. I did however encounter a problem which is partly related. In case the code uses TAB indentation which is to be replaced with SPACE indentation, this is currently only applied to lines which are the wrong indentation level. As a result, the test below fails:
Can you please write a failing test like above for the problem with shows the problem with incorrectly formatted KDoc? |
Oh, I think you meant that there was no file that when formatted should produce the expected behavior. The expected file is the input file, ktlint finds an error where there is none. |
Just reproduced the errors in following test. There seem to be multiple problems when converting space indentation to tabs.
|
I think that the end of line comments are not allowed. Most like the will just be seen as part of the value. So in this case the indent_style is set to |
Take a look at the editorconfig test suite used by ec4j. Looks like line comments on the same line should be ignored, no? |
In PropertyType class of ec4j, the
My guess is that, if EOL comments are really removed, this is done too late in the process. Probably the property is ignored as soon as the value is not found in the list of allowed values ( |
Expected Behavior
Observed Behavior
Steps to Reproduce
ktlint -F whatever.kt
I'm fairly certain that this is the reason for this behavior, i.e. it adds one of whatever indentation (space or tab) instead of one space. I think it's probably best to ignore both
BLOCK_COMMENT
andKDOC
. There also doesn't seem to be a test for that; I think adding a KDoc comment to this test should suffice.I already tried fixing it but didn't really get anywhere; I might open a PR in a few days if I manage to fix it.
Your Environment
.editorconfig
containsindent_style = tab
The text was updated successfully, but these errors were encountered: