This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 188593

Summary: schema enabled xml files attributes auto-completion is broken
Product: xml Reporter: puffneki
Component: Text-EditAssignee: _ alexpetrov <alexpetrov>
Status: VERIFIED FIXED    
Severity: normal CC: ads, mfukala, mmirilovic, pjiricka, vriha
Priority: P2    
Version: 6.x   
Hardware: PC   
OS: Windows Vista   
Issue Type: DEFECT Exception Reporter:

Description puffneki 2010-07-12 13:56:02 UTC
Product Version = NetBeans IDE 6.9 (Build 201006101454)
Operating System = Windows Vista version 6.0 running on amd64
Java; VM; Vendor = 1.6.0_21
Runtime = Java HotSpot(TM) 64-Bit Server VM 17.0-b16

The problem occurs using any valid schema file.
For example using this one:

<pages xmlns="http://jboss.com/products/seam/pages"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://jboss.com/products/seam/pages
http://jboss.com/products/seam/pages-2.1.xsd">
	
</pages>

When i start to type "<page ac" between the <pages> tags the auto-completion pops up, suggesting the attribute "action".
Hit ENTER, and it places the word "action" after the "ac" that i've already typed in. So, now it looks like this:
<pages acaction=""|
with the caret positioned after the second quote.
Comment 1 Sergey Lunegov 2010-07-12 14:14:24 UTC
Alex, please take a look.
Comment 2 tphuocthai 2010-09-20 04:09:27 UTC
This happen again for me for Netbeans 6.9.1 but little bit different.

Product Version: NetBeans IDE 6.9.1 (Build 201007282301)
Java: 1.6.0_20; Java HotSpot(TM) Client VM 16.3-b01
System: Linux version 2.6.32-24-generic running on i386; UTF-8; en_US (nb)

I'm using spring framework with the following schema:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
                    http://www.springframework.org/schema/beans/spring-beans.xsd>

</beans>

When type "<bean " press Ctrl+Space, the auto-complete pop-up with a list of attribute I can select, next type i (for id) then the auto-complete disappear with "No suggestions" message.
Comment 3 _ alexpetrov 2011-03-18 21:59:02 UTC
Fixed in trunk: changeset 191280:4a4c43675944
(http://hg.netbeans.org/main/rev/4a4c43675944).

"Fix for issue [#188593]. XML Code Completion: characters duplication for XML attribute auto-completion."
Comment 4 Quality Engineering 2011-03-19 09:43:08 UTC
Integrated into 'main-golden', will be available in build *201103190400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/4a4c43675944
User: Alex Petrov <alexpetrov@netbeans.org>
Log: Fix for issue [#188593]. XML Code Completion: characters duplication for XML attribute auto-completion.
Comment 5 Petr Jiricka 2011-03-21 09:50:33 UTC
Thanks a lot Alex!
Comment 6 Denis Anisimov 2011-03-21 13:16:08 UTC
The fix looks good.

Please extend the unit test BasicCompletionTest ( see f.e. testAttributes1() )
Comment 7 Marek Fukala 2011-03-21 15:12:36 UTC
The fix introduces a new regression:

1) if the completion is invoked inside the whitespace after the tag name w/o a prefix, then the completed item is inserted at the whitespace token offset, which is the previous non-ws token end offset. For example: <tagname | > + cc => <tagnameid="">. This is a direct the regression of the Alex's fix - setting typedChars field to the token image also for whitespaces.

And another existing problem remains untouched:

2) the completion doesn't work just before a syntax error, which is not nice at least in this case:
<tagname att|> ... the closing symbol is lexed as error token since there's missing the attribute value. I believe such case is pretty common - user just considers to add a new attribute so s/he puts a whitespace and invokes the cc.
Comment 8 Marek Fukala 2011-03-21 15:13:52 UTC
I've fixed both mentioned issues in web-main#478e3746fe59

If anyone is still interested in the review, please do so now.
Comment 9 Marek Fukala 2011-03-23 15:56:42 UTC
Vlado, can you please look at the issue and verify it? I know it's not exactly your area, but I it would help us a lot. Thanks in advance.
Comment 10 Vladimir Riha 2011-03-23 18:04:35 UTC
I'll check it tomorrow
Comment 11 Quality Engineering 2011-03-24 09:52:06 UTC
Integrated into 'main-golden', will be available in build *201103240400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/478e3746fe59
User: Marek Fukala <mfukala@netbeans.org>
Log: #188593 - schema enabled xml files attributes auto-completion is broken
Comment 12 Vladimir Riha 2011-03-24 16:46:04 UTC
Everything seems to work fine, but I noticed that when type "<page ac" and invoke completion, then <page action=""| is completed but the cursor position is at the end (after last " character), not between "". In jsp or html the cursor is placed between "" characters. Is this normal behaviour or is it related to this fix?
Comment 13 Marek Fukala 2011-03-25 21:25:17 UTC
changeset:   195072:0516afc0ecad
branch:      release70
user:        Alex Petrov <alexpetrov@netbeans.org>
date:        Sat Mar 19 00:31:08 2011 +0300
summary:     Fix for issue [#188593]. XML Code Completion: characters duplication for XML attribute auto-completion.

changeset:   195073:72355b89b8b3
branch:      release70
tag:         tip
user:        Marek Fukala <mfukala@netbeans.org>
date:        Mon Mar 21 16:09:10 2011 +0100
summary:     #188593 - schema enabled xml files attributes auto-completion is broken