Niklas Matthies created NETBEANS-36:
---------------------------------------

             Summary: 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)

Reply via email to