Menu

#522 Broken automatic comment bracketing

2: Annoying
closed-fixed
7
2006-09-02
2006-08-24
Dan Smith
No

The automatic multi-line commenting behavior is messed up when I
put text on the first line. For example, the following (pipe is the
cursor):

/** |

Becomes this after hitting enter:

/**
* |
*/

But this:

/** Some text|

Becomes this with an enter:

/** Some text
*/|

Here, the cursor appears *after* the end-of-comment token, and I
have to manipulate the cursor to get back inside the comment.

Worse, breaking the first line:

/** My |comment */

rearranges the text:

/** My
*/|comment */

The word "comment" here is no longer inside of the comment.

The logic seems to be messed up somewhere.

Discussion

  • Mathias Ricken

    Mathias Ricken - 2006-08-25

    Logged In: YES
    user_id=1075744

    It took me a while to realize that the setting
    "Automatically Close Block Comments" needs to be checked in
    Preferences/Miscellaneous. After I checked that, I was able
    to verify your bug report.

    As for the first problem, what do you think should be the
    result?

    /** Some test|

    goes to

    /** Some test|
    */

    or

    /** Some test
    * |*/

    or

    /** Some test
    * |
    */

    For the second problem, it's quite clear that

    /** My |comment */

    should become

    /** Some
    * test. *

     
  • Mathias Ricken

    Mathias Ricken - 2006-08-25
    • priority: 5 --> 7
     
  • Dan Smith

    Dan Smith - 2006-08-25

    Logged In: YES
    user_id=1060117

    I think the most natural approach to take here:

    /** Some test|

    Is the one we take here:

    /** |

    That is, insert two new lines, one continuing the comment and one ending it:

    /** Some test
    * |
    */

    (The only difference here is that '*'s are indented two spaces, not one.)

     
  • Robert Cartwright

    Logged In: YES
    user_id=430590

    When I briefly tried the "Automatically close block
    comments" option a long time ago, I found the conventions
    were counter-intuitive. How does the IDE know when to
    insert a closing bracket and where? It almost never did
    what I wanted It reminds me of the absurd automatic
    capitalization conventions in Microsoft Word/Powerpoint.

    My inclination is to simply eliminate this feature (which
    eliminates the bug) but I am open to other opinions. For
    those of us who believe in conserving vertical space in
    code, automatically forcing every block comment (e.g.,
    javadoc comments) to span at least 3 lines is very distasteful.

     
  • Robert Cartwright

    Logged In: YES
    user_id=430590

    In the latest build, the only bug that I can reproduce is a
    variation on the last one, which looks like a logic error in
    the code to automatically close comments. With the current
    build, you get the text:
    /* My
    * |comment */
    */

    where the "c" is directly underneath the "M" and the cursor
    precedes the "c".

    This behavior is clearly not what we want.

    Here is my proposal for how DrJava should behave in this
    mode. The only situation in which DrJava should insert a
    closing "*/" comment bracket is when <enter> is typed at the
    END of the opening line of a comment. In this case, it
    should automatically place "* " on the next line followed by
    the cursor and "*/" on the following line (as shown in the
    first example above). The existing auto-indenting rules
    will be used to determine how many spaces are inserted
    before the "*" characters on each of the two new lines.

    Note that if <enter> is typed at the end of the first line
    of an existing comment, the specified two-line nsertion
    happens, but this should be an unusual event.

     
  • Mathias Ricken

    Mathias Ricken - 2006-09-01

    Logged In: YES
    user_id=1075744

    When "automatically close comments" is enabled, I can still
    reproduce other problems:

    /** Foo |bar */

    on return becomes

    /** Foo
    */|bar */

    and

    /** Foo bar|

    on return becomes

    /** foo bar
    */|

    I don't think these issues have been resolved.

     
  • Robert Cartwright

    Logged In: YES
    user_id=430590

    I commited a source revision that apparently fixes this bug.
    Check it out.

     
  • Mathias Ricken

    Mathias Ricken - 2006-09-02
    • assigned_to: nobody --> rcartwright
    • status: open --> closed-fixed
     

Log in to post a comment.