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

Bug 219992

Summary: [content assist] Incorrect insertion of value with help of content assist in some case
Product: [WebTools] WTP Source Editing Reporter: Andrei Scherbovich <ascherbovich>
Component: wst.htmlAssignee: Salvador Zalapa <zalapa>
Status: RESOLVED FIXED QA Contact: Nitin Dahyabhai <thatnitind>
Severity: minor    
Priority: P3 CC: itewksbu, nsand.dev
Version: 2.0.1Keywords: helpwanted
Target Milestone: 3.4.1Flags: nsand.dev: review+
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Initial patch nsand.dev: iplog+

Description Andrei Scherbovich CLA 2008-02-22 12:03:17 EST
Build ID:  M20070921-1145

Steps To Reproduce:
EXECUTE: Create test.html:
<html dir=  lang="" >
</html>
EXCUTE: Ctrl+Space at <html dir= |
EXCUTE: Choose "ltr". Enter.
FAILURE: We got <html dir= "ltr""" >

More information:
Comment 1 Nitin Dahyabhai CLA 2008-02-25 22:50:02 EST
Not sure there's much that can be done here.  The presence of the first '=' combined with lack of an attribute value makes the "lang" attribute name be interpreted as the value of the "dir" attribute.
Comment 2 Ian Tewksbury CLA 2010-02-01 16:11:37 EST
I think a solution can be found here because invoking content assist at
<html dir=|  lang="" >
results in:
<html dir="ltr"  lang="" >

while
<html dir= | lang="" >
results in
<html dir=  "ltr""" >


Thus whatever is being done for the first case should be done for the second case, most likely having to do with some trickery of the location of the cursor and the = that could be expanded to include whites pace after the =.
Comment 3 Salvador Zalapa CLA 2012-06-06 23:13:28 EDT
Created attachment 216991 [details]
Initial patch
Comment 4 Salvador Zalapa CLA 2012-06-06 23:13:57 EDT
Attaching an initial proposed patch. It consist in skiping the replacement of the region, when the offset is not at the beginning of the region, only when the region is XML_TAG_ATTRIBUTE_EQUALS.

Example:  <html dir= | lang="" >
result:   <html dir= "ltr" lang="" >

I already run the following junits with successful results:
org.eclipse.wst.xml.ui.tests
org.eclipse.wst.html.ui.tests
org.eclipse.wst.css.ui.tests
Comment 5 Nick Sandonato CLA 2012-06-07 16:21:04 EDT
Hi, Chava. Thanks for taking a look at this.

Another scenario that I just tried was
<html dir= |lang="en">

and this caused the lang= to be consumed similar to the other scenario. Would it be possible to correct that as well?
Comment 6 Salvador Zalapa CLA 2012-06-12 10:46:46 EDT
Hello Nick:
On that particular scenario the completionRegion is recognized as XML_TAG_ATTRIBUTE_VALUE, that is why in AbstractXMLCompletionProposalComputer.computeAttributeValueProposals, the setup is to replace the existing value ( in this case lang=). As Nitin says in comment #2, so far i think there is no much we can do.
Comment 7 Nick Sandonato CLA 2012-06-12 10:48:24 EDT
Understood and I agree. Thanks, Chava.
Comment 8 Nick Sandonato CLA 2012-08-10 16:38:38 EDT
Changes pushed.
Comment 9 Nick Sandonato CLA 2012-08-10 16:39:08 EDT
.