Bug 218999 - [templates] Leading whitespace is trimmed from a Java Editor Templates before insertion
Summary: [templates] Leading whitespace is trimmed from a Java Editor Templates before...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P5 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-14 13:32 EST by Simon Archer CLA
Modified: 2008-02-15 10:51 EST (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 Simon Archer CLA 2008-02-14 13:32:39 EST
If you have a Java Editor Template that has leading whitespace it is trimmed off before the template is inserted into the Java editor.  For some templates leading whitespace is valuable, so it would be nice if templates were inserted verbatim.
Comment 1 Dani Megert CLA 2008-02-15 03:35:21 EST
Simon, do you have a concrete example?
Comment 2 Simon Archer CLA 2008-02-15 08:53:56 EST
I had added an nls1 template that inserted " //$NON-NLS-1$", and I always wanted the leading space.  Likewise for the default nls template, since I did not want multiple NLS tags to run together. I realize that this is a minor gripe, but regardless, it makes sense that if the template includes leading, or trailing, whitespace that it be honored.  Thanks.
Comment 3 Dani Megert CLA 2008-02-15 09:23:44 EST
Why do you need the NLS template? There's a quick fix for this which does the trick for you ;-)

We auto-indent the whole template for you and run it through the formatter (the latter can be disabled). To make this right we would have to introduce some sort of hard (white)space.
Comment 4 Simon Archer CLA 2008-02-15 10:51:51 EST
Clearly the use-case here is pretty narrow, so I would not want you to invest too much into this.  If it's easy to just respect leading/trailing whitespace (as in, don't call trim() before insertion), then I'd say, just do it, otherwise, I would not mind this being shelved.  Thanks.