Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 361372 - the usage of ${line_selection} and ${line_selection} templates breaks typing in editor
Summary: the usage of ${line_selection} and ${line_selection} templates breaks typing ...
Status: REOPENED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: PDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 critical (vote)
Target Milestone: ---   Edit
Assignee: PHP Core CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-19 06:55 EDT by Kalin CLA
Modified: 2020-05-14 10:17 EDT (History)
0 users

See Also:


Attachments
screenshot-step1 (27.01 KB, image/jpeg)
2011-10-19 06:57 EDT, Kalin CLA
no flags Details
screenshot-step2 (9.10 KB, image/jpeg)
2011-10-19 06:58 EDT, Kalin CLA
no flags Details
screenshot-step3 (7.35 KB, image/jpeg)
2011-10-19 06:58 EDT, Kalin CLA
no flags Details
screenshot-step4 (23.53 KB, image/jpeg)
2011-10-19 06:58 EDT, Kalin CLA
no flags Details
New_step1 (21.91 KB, image/jpeg)
2012-07-06 06:41 EDT, Kalin CLA
no flags Details
New_step2(reslult) (13.04 KB, image/jpeg)
2012-07-06 06:42 EDT, Kalin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kalin CLA 2011-10-19 06:55:35 EDT
Typing code in editor seems broken after you have used php template with variable ${line_selection} or ${word_selection}

Scenario:
Go to Preferences>PHP>Editor>Templates > Press New button. 
In Add template dialog press Insert Variable button . 
Add ${line_selection} in Pattern list.
Type testlineselection in Name field.
Save the new added template.

Open a php file in editor.

Type some valid code, e.g.

<?php 
class CCC {
	function fff() {
		echo "test";
	}
}

Select the whole class and it body (lines 2 to 6), then invoke Content Assist and type part of template name, e.g. "test"
You will see the suggested template in CA list.
Select it in CA list.

Problem 1:
First 4 chars of the template will be placed in editor, since you typed 4 chars ("test") of template name ("testlineselection")


Problem 2 
If you try to continue typing you will see the cursor goes unexpectedly at the beginning of line 2, then it goes to line 1 just before opening php tag <?php
The cursor cannot be moved from this position by typing anymore.

Just in a few seconds the error becomes as much as 1 MB size.
Comment 1 Kalin CLA 2011-10-19 06:56:19 EDT
Similar problem when you use ${word_selection} template.
Comment 2 Kalin CLA 2011-10-19 06:57:48 EDT
Created attachment 205493 [details]
screenshot-step1
Comment 3 Kalin CLA 2011-10-19 06:58:13 EDT
Created attachment 205495 [details]
screenshot-step2
Comment 4 Kalin CLA 2011-10-19 06:58:32 EDT
Created attachment 205496 [details]
screenshot-step3
Comment 5 Kalin CLA 2011-10-19 06:58:56 EDT
Created attachment 205497 [details]
screenshot-step4
Comment 6 Kalin CLA 2011-10-19 07:00:11 EDT
Saving the file does not solve the problem.

The only workaround:
Close the file and open it again.
Comment 7 Zhongwei Zhao CLA 2011-11-22 06:28:26 EST
fixed
Comment 8 Kalin CLA 2012-07-06 06:41:30 EDT
I re-tested the problem.
Now if you select the template in Content Assist list you will get nothing added in editor and the cursor just goes to the first position on the line.
Of course you have to select the whole class and its body in advance (as described in the issue.) See the new attachment.

This happens for ${line_selection}
The same problem for ${word_selection}

Reopening...
Comment 9 Kalin CLA 2012-07-06 06:41:53 EDT
Created attachment 218376 [details]
New_step1
Comment 10 Kalin CLA 2012-07-06 06:42:26 EDT
Created attachment 218377 [details]
New_step2(reslult)