Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 355280 - [Code templates] Extra white space inserted when using ${word_selection}
Summary: [Code templates] Extra white space inserted when using ${word_selection}
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-editor (show other bugs)
Version: 8.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-19 18:41 EDT by Marc-André Laperle CLA
Modified: 2020-09-04 15:20 EDT (History)
3 users (show)

See Also:


Attachments
Remove white space when using ${word_selection} template (1.40 KB, patch)
2012-01-08 22:38 EST, Simon Ducharme Boutin CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marc-André Laperle CLA 2011-08-19 18:41:45 EDT
I'm using CDT 8.0.0.201108031635

1. Create a template containing ${word_selection}
2. Use the template on a word on a line that starts with some white space
3. Extra white space is inserted

Note: It doesn't seem to matter if the "Use code formatter" option is checked or not.

Example:

template : ${word_selection}

int main() {
    return 0;
}

When template is used on 'return':
int main() {
    	return 0;
}
Comment 1 Simon Ducharme Boutin CLA 2012-01-08 22:38:32 EST
Created attachment 209182 [details]
Remove white space when using ${word_selection} template
Comment 2 Marc-André Laperle CLA 2012-01-09 01:02:46 EST
(In reply to comment #1)
> Created attachment 209182 [details]
> Remove white space when using ${word_selection} template

Thanks for looking at this. I don't think trim will give the best results. Here's an example:

template:
cout << "${word_selection}"

code:

    foo    ;
^      ^
note the 4 spaces before and 4 spaces after foo.

Select foo and the 4 subsequent spaces (up to ; but ; not selected). Invoke the template: white space is inserted before the cout and white space is lost after 'foo'. Also, if I test the original example, it still inserts spaces. Make sure you select only 'return' without the white spaces before it.