Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Enter before indented Java line comment removes indentation

Abierto
#9,440 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
68/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
java
Área
tooling

Línea de trabajo

Reproduce el problema en NetBeans Java Editor utilizando el ejemplo y con el cursor al inicio de un comentario de línea indentado. Rastrea el manejo de la tecla Enter para los comentarios de línea y compáralo con los comentarios de bloque y las instrucciones ordinarias. Se considera terminado cuando la indentación se conserva al insertar una línea antes de cualquiera de los dos comentarios, con cobertura de regresión para los casos reportados.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Java kind:bug needs:triage
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

Lenguaje dominante
Java
Estrellas
3.1k
Forks
939
Merge medio
4 d 21 h
PR fusionados (30 d)
24

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/netbeans

Todos los issues de apache/netbeans

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.