Skip to content
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

Edge case with annotations #42

Open
jlkeesey opened this issue Jun 6, 2022 · 3 comments
Open

Edge case with annotations #42

jlkeesey opened this issue Jun 6, 2022 · 3 comments

Comments

@jlkeesey
Copy link

jlkeesey commented Jun 6, 2022

I have code like below that has an annotation above the comment because I need to suppress spell checking in the comment. If I
do that the the comment is indented 8 spaces (continuation indentation). This happens on a function, not a class. All of the rest of the code and comments are indented properly.

@Suppress("SpellCheckingInspection")
        /**
         * Lorem ipsum dolor sit amet, consectetur adipiscing elit.
         */
fun KDocFormatterTest() {
}
@tnorbye
Copy link
Owner

tnorbye commented Jul 27, 2022

I can't reproduce this. Can you say more about how to reproduce it? Was it in the IDE, or from the command line? (I did fix a bug recently where the formatter misbehaved if the kdoc comment starts at the end of a line (E.g. there is non-whitespace on the beginning line of the comment) but that doesn't seem to be the case here.

@jlkeesey
Copy link
Author

It was in an IDE (IntelliJ) as I do all of my work there. I have never tried the command line (my mistake I should have before reporting). I will try it again and also from the command line.

@tnorbye
Copy link
Owner

tnorbye commented Jul 28, 2022

I see! In the IDE, this plugin doesn't decide where the comment itself gets indented; it only reformats the internal contents within the comment; the actual indentation of where the comment is located is decided by the Kotlin plugin formatter.

The same is (almost) the case for the command line formatter. It doesn't try to format/reindent any non-comment elements; only the comment. (However, if the comment is at the ending of a line with code on it, and it cannot fit the comment fully on the line, then it does go and push the whole comment to the next line (by reusing the indentation it finds there (well, in the next version anyway)); that's the only time when it actually affects where the comment itself is indented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants