Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 355280

Summary: [Code templates] Extra white space inserted when using ${word_selection}
Product: [Tools] CDT Reporter: Marc-André Laperle <malaperle>
Component: cdt-editorAssignee: Project Inbox <cdt-editor-inbox>
Status: NEW --- QA Contact: Jonah Graham <jonah>
Severity: normal    
Priority: P3 CC: cdtdoug, sducharme, yevshif
Version: 8.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Remove white space when using ${word_selection} template none

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.