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

Bug 105912

Summary: Pasted text contains only one space if clipboard content starts with tab
Product: [WebTools] WTP Source Editing Reporter: Andrey Loskutov <loskutov>
Component: wst.sseAssignee: David Williams <david_williams>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P2 CC: david_williams, for.work.things, mhilpert, wyuenho
Version: 0.7   
Target Milestone: 1.0 M7.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
org.eclipse.jst.jsp.ui.patch
none
org.eclipse.wst.xml.ui.patch
none
org.eclipse.wst.html.ui.internal.autoedit.patch none

Description Andrey Loskutov CLA 2005-08-03 09:46:40 EDT
Test case: all WTP plugins are configured to use spaces instead of tabs for 
identing. 
Open an jsp file which is idented with tabs. Copy any line(s) which starts with 
the tab character and contains at least one non-whitespace character to the 
clipboard, and then paste it somewhere back in the editor. The pasted text 
contains only one space. All non-whitespace characters are gone...
I think this is somehow related to bug 71271.

Test text in the jsp:

	<tiles:put name="resultForm" direct="true">
		<tiles:insert attribute="resultForm" />
	</tiles:put>

Result text after copy in clipboard and paste back to the editor: <one space 
character>. The clipboard contains the whole copied text (I can paste it in 
UltraEdit), also the error should occur by pasting the clipboard content back to 
the jsp editor.
Comment 1 Amy Wu CLA 2005-08-03 11:17:11 EDT
Yes, you are indeed correct this bug is related to the fix for bug 71271.  
Namely the autoeditstrategyfortabs.  It is currently checking for if any 
content is inserted into the editor and starts with a tab character, the whole 
content is replaced with the appropriate space character only.

Hmm.  I know I can fix it such that if any content is inserted into the editor 
and that content is exactly 1 tab character, the tab character is replaced by 
the appropriate space characters.  Would people mind if they copied a tab 
character and it pasted as spaces instead?
Comment 2 Andrey Loskutov CLA 2005-08-03 11:35:39 EDT
I think, inserting text in editor where clipboard contains leading whitespace 
should always follow the tabs/spaces preferences of current editor and then 
replace leading characters with appropriated before inserting to the file.

Then if I have selected, that I always should get spaces by hitting the "tab" 
key, then I would also expect, that all leading tabs are to be converted if I 
paste them to editor. Otherwise I would get an *unexpected* "mix" in the source.

Anyway, all non-whitespace chars should be preserved ;)
Comment 3 Amy Wu CLA 2005-08-03 12:52:35 EDT
agreed that all non-whitespace characters should be preserved :)

okay, i don't know about the fixing up leading whitespace when you paste.  
that may be a whole separate new enhancement for auto-indenting.

but i think what i can do is fix the code so that if you do have the indent 
using spaces preference set, all tab characters pasted in the editor will be 
converted to spaces, leading or not.  this appears to be what java editor does.
Comment 4 David Williams CLA 2005-08-04 11:01:44 EDT
*** Bug 105657 has been marked as a duplicate of this bug. ***
Comment 5 David Williams CLA 2005-08-04 11:02:32 EDT
moving to 'major', p2 to honor the client's severity in the dup'd bug report. 
Comment 6 Amy Wu CLA 2005-08-05 12:46:38 EDT
Created attachment 25760 [details]
org.eclipse.jst.jsp.ui.patch
Comment 7 Amy Wu CLA 2005-08-05 12:46:49 EDT
Created attachment 25761 [details]
org.eclipse.wst.xml.ui.patch
Comment 8 Amy Wu CLA 2005-08-05 12:47:00 EDT
Created attachment 25762 [details]
org.eclipse.wst.html.ui.internal.autoedit.patch
Comment 9 Amy Wu CLA 2005-08-05 12:52:47 EDT
Fixed AutoEditStrategyForTabs in xml, html, jsp so that when you have the 
indent using spaces preference set AND you are in smart insert mode, any tab 
character you enter into the editor will be converted to spaces.  also fixed 
the original problem so non-whitespace characters are left alone when you 
paste.

reassigning to nitin to apply patches
Comment 10 Nitin Dahyabhai CLA 2005-08-10 23:24:36 EDT
Patches applied to HEAD.  Thanks, Amy.
Comment 11 David Williams CLA 2005-09-20 11:14:13 EDT
re-opening for consideration for 0.7.1, since there are 
many reports from users of failures that might be related to this. 
Comment 12 David Williams CLA 2005-09-20 11:17:01 EDT
I'll take a look on 07 stream and be sure "compatible" with it before 
releasing. 
Comment 13 David Williams CLA 2005-09-20 11:22:22 EDT
*** Bug 108339 has been marked as a duplicate of this bug. ***
Comment 14 David Williams CLA 2005-09-20 17:41:53 EDT
Released for 0.7.1 build. expect in M builds > 9/20. 

Comment 15 David Williams CLA 2006-09-22 20:51:58 EDT
This bug is being moved to the "closed" state since it has been in the fixed state for a so long it is being assumed fixed, without explicit verification from the originator. If there is still a problem, in the most recent 1.5.x builds, please reopen or open another bug.