netbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niklas Matthies (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (NETBEANS-36) Statement indentation after commented-out Java statements
Date Wed, 12 Jul 2017 23:22:00 GMT

    [ https://issues.apache.org/jira/browse/NETBEANS-36?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16084893#comment-16084893
] 

Niklas Matthies commented on NETBEANS-36:
-----------------------------------------

A related misbehavior is the following: When you have a line comment that is indenten, i.e.
it does not start in column 0, and the caret is right at the initial slash, then pressing
{{Return}} removes the indentation in front of the line comment instead of maintaining it.

> Statement indentation after commented-out Java statements
> ---------------------------------------------------------
>
>                 Key: NETBEANS-36
>                 URL: https://issues.apache.org/jira/browse/NETBEANS-36
>             Project: NetBeans
>          Issue Type: Bug
>          Components: java - Editor
>    Affects Versions: 8.2
>            Reporter: Niklas Matthies
>
> Within a method body, when pressing {{Return}} at the start of a statement behind a comment,
the resulting indentation is set to the start of the comment line. As illustrated by the following
example, this generally isn't useful. Comments should be ignored when determining indentation
outside of a comment.
> Example:
> {code:java}
>     void someMethod() {
>         someStatement();
>         someOtherStatement();
>     }
> {code}
> Commenting out the first statement by pressing {{Ctrl+/}} results in:
> {code:java}
>     void someMethod() {
> //        someStatement();
>         someOtherStatement();
>     }
> {code}
> I.e. the comment is placed at the very beginning of the line. Then, pressing {{Return}}
when the caret is right at the beginning of the second statement (e.g. to add an empty line
behind the comment) results in the following:
> {code:java}
>     void someMethod() {
> //        someStatement();
> someOtherStatement();
>     }
> {code}
> I.e. the second statement is indented to the start of the comment above. This should
not happen. Instead, indentation should be determined as if the comment wasn't there (because
it's a comment and not code). In other words, the expected result is:
> {code:java}
>     void someMethod() {
> //        someStatement();
>         someOtherStatement();
>     }
> {code}
> Note that, on the other hand, when pressing {{Return}} when the caret is at the end of
the comment line, then it makes sense to indent the new line to the start of the comment,
for continuation of the comment. The difference to the situation above is that here the caret
is within the comment when {{Return}} is being pressed, while in the case above the caret
is outside the comment.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message