nmatt opened a new issue, #9440:
URL: https://github.com/apache/netbeans/issues/9440
### 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:
```java
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:
```java
class Example
{
Example()
{
int x = 5;
// some comment
// second line
int y = 7;
}
}
```
The same happens when pressing Enter before subsequent line comments:
```java
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):
```java
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:
```java
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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists