Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Enter before indented Java line comment removes indentation

オープン
#9,440 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
java
領域
tooling

調査の方向性

例と、インデントされた行コメントの先頭に caret がある状態を使って、NetBeans Java Editor で問題を再現します。行コメントに対する Enter キーの処理を追跡し、ブロックコメントおよび通常の文の場合と比較します。いずれかのコメントの前に行を挿入したときにインデントが保持され、報告されたケースに対する回帰テストが含まれていれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
Java
スター
3.1k
フォーク
939
平均マージ
4日 21時間
マージ済み PR(30日)
24

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/netbeans のほかの issue

apache/netbeans の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。