Bug 71365 - [templates] code template comments are formatted badly
Summary: [templates] code template comments are formatted badly
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-04 07:30 EDT by Nicolas de Jong CLA
Modified: 2009-10-26 12:04 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas de Jong CLA 2004-08-04 07:30:41 EDT
I find it esthetically pleasing to have an extra space in front of my remarks,
except the first line. Remark templates were changed for that for all types, in
the form

/** remark
  * remark
  */

This will fail (i.e. be ignored) for getters, setters, constructors, types,
fields, methods and overriding methods (all possible remark prefs) and be showed as:

/** remark
 * remark
 */

Also pressing enter after typing /** will add a * below the first * in stead of
the second *.

It's minor, but the remark template configuration exists so it should be
expected that it works.
Comment 1 Olivier Thomann CLA 2004-08-04 13:33:56 EDT
Move to JDT/Text
Comment 2 Dani Megert CLA 2004-08-06 05:18:30 EDT
can be reproduced using I200408041200.
Comment 3 Dani Megert CLA 2005-10-19 04:16:21 EDT
*** Bug 112965 has been marked as a duplicate of this bug. ***
Comment 4 David Rothenberger CLA 2005-10-19 19:03:08 EDT
(In reply to comment #3)
> *** Bug 112965 has been marked as a duplicate of this bug. ***

I'm not entirely sure why 112965 was marked as a duplicate.

In that bug, I have a template of the form:

/*
 * line 1
 * line 2
 */

When that template is inserted, it's formatted as:

/*
* line 1
* line 2
*/

This is without the code formatter enabled for that template.

This is a regression from 3.1. It worked fine in 3.1 and is no longer working in
3.1.1. This is why I'm confused about it being a duplicate of this bug, since
this bug was reported against 3.0.
Comment 5 Dani Megert CLA 2005-11-09 13:17:32 EST
If you format the file you loose your style again right?

This can either be support by offering to disable the formatter when using code
templates (similar to normal templates) or add an option to the formatter.
Comment 6 Nicolas de Jong CLA 2005-11-09 15:45:10 EST
> If you format the file you loose your style again right?

/** When I press enter after this line
 * the indentation is wrong on the second line.
 * so I have to add a space before each line,
 * except the first.
 */

/** When I added spaces and the remark looks as
  * configured in the template, after I format
  * the file again, the state of all remarks
  * are back to the original state from the
  * previous paragraph.
  */

> This can either be support by offering to disable the formatter
> when using code templates (similar to normal templates) or add
> an option to the formatter.

That is not support, that is a workaround, i.e. not using the
formatter for remarks. This bug report was created in the hope
that the bug in the remark templates would be fixed.

Therefore I don't understand why you see this bug as an enhancement
request. Trivial perhaps (though annoying because I'm confronted with
it everytime I write remarks in my code), but not an enhancement
because this feature does not work as advertised.
Comment 7 Nicolas de Jong CLA 2006-04-20 08:19:26 EDT
I have no idea if anything is done on this issue, but I have another problem that is a consequence of using the changed code templates.

When I copy

    /** The text here tells something about the use and
      * implementation of this method.
      */
    public void someMethod() {
    	// empty
    }

and paste again, all lines except the first (the /** line) will be indented one less. Paste again and one less, etc. This happens when the 'spaces for tabs' option is set and is not formatter related (as far as I can tell)

I can work around the code template bug using a java code beautifier that supports my silly remark fetish but the copy and paste is not very handy, especially if I decide to copy a somewhat larger method I have to add a space
in front of each line.

If I have to add this issue as a new bug, please let me know.

I realise that this is a bug that has very low priority, but if the indentation problem can be easily fixed that would be much appreciated.
Comment 8 Tom Hofmann CLA 2006-04-20 08:52:22 EDT
Re. comment 7: you can disable auto-indent-on-paste on the Java > Editor > Typing preference page.
Comment 9 Nicolas de Jong CLA 2006-04-20 09:02:59 EDT
That's a two edged sword, because copy/paste to move parts of code around now doesn't indent automatically anymore too, but it helps with my problem and this way is easier than before. I'll use alt-cursor to move code around instead (fortunately that still indents correctly).

Thank you for mentioning this, that helps me a lot.