Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Enter before indented Java line comment removes indentation

Aperta
#9,440 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
java
Ambito
tooling

Direzione di ricerca

Riproduci il problema in NetBeans Java Editor utilizzando l’esempio e con il cursore all’inizio di un commento di riga indentato. Traccia la gestione del tasto Enter per i commenti di riga e confrontala con quella dei commenti a blocco e delle istruzioni ordinarie. Il lavoro è completato quando l’indentazione viene mantenuta inserendo una riga prima di uno dei due commenti, con copertura di regressione per i casi segnalati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
Java
Stelle
3.1k
Fork
939
Merge medio
4g 21h
PR unite (30g)
24

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/netbeans

Tutte le issue di apache/netbeans

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.