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 22291

Summary: Code completion of "</" should directly insert the end tag
Product: xml Reporter: Asgeir Asgeirsson <asgeir>
Component: Text-EditAssignee: _ pkuzel <pkuzel>
Status: VERIFIED FIXED    
Severity: blocker    
Priority: P3    
Version: 3.x   
Hardware: PC   
OS: Windows ME/2000   
Issue Type: ENHANCEMENT Exception Reporter:
Attachments: org.netbeans.modules.xml.text.completion.XMLCompletionQuery after changing v1.10

Description Asgeir Asgeirsson 2002-04-10 14:58:31 UTC
When writing "</" the completion popup window suggests the 
apropreate closing tag.  To insert the closing tag I have 
to press enter.  

When someone writes "</" in XML, he is defenetely closing 
an open tag.  The tag should thus be inserted 
automatically without requireing the user to press enter.

Most XML editors I know of do it that way, and I think 
this editor should do this too.

Following changes in the 
org.netbeans.modules.xml.text.completion.XMLCompletionQuery
 class will fix this:

In the 
query(JTextComponent component, int offset, SyntaxSupport 
support)
method the following line:

                    return null;  //??? end tag handling

should be replaced by:

                    if (preText.endsWith("</") && 
token.getTokenID().getNumericID() == 
XMLDefaultTokenContext.TEXT_ID) {
                        list = findStartTag((SyntaxNode)
element);
                        if (list != null && list.size() == 
1) {
                            ElementResultItem item = 
(ElementResultItem)list.get(0);
                            item.substituteText(component, 
offset, 0, 0);
                        }
                    }
                    return null;  //??? end tag handling

And in the 
query(SyntaxNode element, TokenItem token, String text)
method the following lines should be commented out:

                } else if ( text.endsWith("</" )) {
                    return findStartTag((SyntaxNode)
element);

I will attach the the changed file.  The changes can be 
better viewed by diffing it to version 1.10.
Comment 1 Asgeir Asgeirsson 2002-04-10 15:02:15 UTC
Created attachment 5357 [details]
org.netbeans.modules.xml.text.completion.XMLCompletionQuery after changing v1.10
Comment 2 _ pkuzel 2002-04-10 15:48:51 UTC
Nice enhancement!

Thank you, I have applied it

PS: why do not use "cvs di" next time?
Comment 3 Mikhail Matveev 2007-11-09 15:12:01 UTC
Verified