Apache NetBeans version
Apache NetBeans 30
What happened
When pressing Enter immediately in front of an indented Java line comment, the indentation of the line comment is not maintained. This is inconsistent with the behavior of pressing Enter before other indented elements.
It is also inconsistent with pressing Enter on an earlier column before the start of the line column, which does maintain the comment's indentation.
It is furthermore inconsistent with the behavior of pressing Enter on front of a block comment (/* ... */), even for a single-line one.
Language / Project Type / NetBeans Component
Java, Editor
How to reproduce
Example:
class Example
{
Example()
{
int x = 5;
// some comment
// second line
int y = 7;
}
}
With the input caret at the beginning of "//" (column 9), pressing Enter (to insert a line before the comment) results in the indentation of the line comment being removed:
class Example
{
Example()
{
int x = 5;
// some comment
// second line
int y = 7;
}
}
The same happens when pressing Enter before subsequent line comments:
class Example
{
Example()
{
int x = 5;
// some comment
// second line
int y = 7;
}
}
This is inconsistent with how indentation behaves for non-comment lines. For example, pressing Enter before int maintains the indentation of the statement.
When pressing Enter at an earlier column, for example on column 8, the indentation of the comment is maintained (however the indentation of the now-empty line before the caret is correspondingly shorter):
class Example
{
Example()
{
int x = 5;
← empty line ends here
// some comment
// second line
int y = 7;
}
}
Compare also with the behavior for a block comment, which remains properely indented when pressing Enter in front of it:
class Example
{
Example()
{
int x = 5;
/* block comment */
int y = 7;
}
}
Did this work correctly in an earlier version?
No / Don't know
Operating System
Windows 11
JDK
JDK 21
Apache NetBeans packaging
Apache NetBeans binary zip
Anything else
No response
Are you willing to submit a pull request?
No
Apache NetBeans version
Apache NetBeans 30
What happened
When pressing Enter immediately in front of an indented Java line comment, the indentation of the line comment is not maintained. This is inconsistent with the behavior of pressing Enter before other indented elements.
It is also inconsistent with pressing Enter on an earlier column before the start of the line column, which does maintain the comment's indentation.
It is furthermore inconsistent with the behavior of pressing Enter on front of a block comment (
/* ... */), even for a single-line one.Language / Project Type / NetBeans Component
Java, Editor
How to reproduce
Example:
With the input caret at the beginning of "//" (column 9), pressing Enter (to insert a line before the comment) results in the indentation of the line comment being removed:
The same happens when pressing Enter before subsequent line comments:
This is inconsistent with how indentation behaves for non-comment lines. For example, pressing Enter before
intmaintains the indentation of the statement.When pressing Enter at an earlier column, for example on column 8, the indentation of the comment is maintained (however the indentation of the now-empty line before the caret is correspondingly shorter):
Compare also with the behavior for a block comment, which remains properely indented when pressing Enter in front of it:
Did this work correctly in an earlier version?
No / Don't know
Operating System
Windows 11
JDK
JDK 21
Apache NetBeans packaging
Apache NetBeans binary zip
Anything else
No response
Are you willing to submit a pull request?
No