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.
Summary: | [69cat] XML autocomplete doesn't override highlighted text | ||
---|---|---|---|
Product: | xml | Reporter: | qbeukes <qbeukes> |
Component: | Text-Edit | Assignee: | Svata Dedic <sdedic> |
Status: | RESOLVED WONTFIX | ||
Severity: | blocker | CC: | alexpetrov, epdv, hmichel, jkovalsky, misterm, tphuocthai |
Priority: | P3 | Keywords: | NETFIX |
Version: | 6.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: | |
Attachments: |
Fix for xml.text module
Fix for xml.schema.completion module Proposed patch to fix xml.text Editor just prior to finishing code completion Editor just after finishing code completion sample XML for use with plugin.xsd Schema for plugin.xml |
Description
qbeukes
2009-10-03 19:13:21 UTC
This annoying bug isn't fixed since several weeks, already: XML editing with code completion, e.g. for xsl files, inserts additional characters - or, better: it doesn't replace the already manually typed characters correctly. Here it is how it works (t = manually typed characters, c = characters from code completion, e.g. "xsl:text": If You have typed "<tttt", after completion You'll have "<cccccccctttt". Seems the bug is in xml.text/src/org/netbeans/modules/xml/text/completion/XMLResultItem.java, method "public void defaultAction(JTextComponent component)". For some unknown reason, probably "substituteOffset" has not been set (yet), resulting in a replace length of zero (thus, not replacing anything, only inserting). Sorry, I've neither the environment to debug this, nor the time to dig deeper into the source. It seems like part of the bug was fixed. I originally reported it for attributes and they do override the highlighted part when using auto complete, though element names are still buggy and not overridden. Are you sure? I can still reproduce this in 6.9 development build #201004070201: 1. Generate new Java Desktop Application with Database shell using built-in Derby database. 2. Open "Source Packages > META-INF > persistence.xml" file. 3. Switch from GUI to XML based editor. 4. Double click RESOURCE_LOCAL to select it and push Ctrl+Space. 5. Select JTA and press Enter. Result will be RESOURCE_LOCALJTA instead of JTA. 6. The same applies for attributes or elements. Adding this bug to NetFIX Pool [1]. If module owner disagrees, please speak up! [1] http://wiki.netbeans.org/NetFIXIssues *** Bug 181288 has been marked as a duplicate of this bug. *** This is valid for ant script file too. I will take a look at this. Well, I found the problem for XML/ant files but looks like I will need to fix it in diferrent modules. Should I break this issue in several, one for each module? Imagine the following scenario for an ant file, with no selection: <import file="nbproject/build-impl.xml" optional="|f"/> which is the desired behaviour? 1. <import file="nbproject/build-impl.xml" optional="false|"/> 2. <import file="nbproject/build-impl.xml" optional="false|f"/> 3. <import file="nbproject/build-impl.xml" optional="falsef|"/> Well, my personal felling is that the best choice is the item 1. Alex, please take a look. Just to be clear, the desired behaviour is when user hit cc and choose an option, in this case user selected always option 'false'. I already create a patch that works for some kind of XML files but I need to know about it to make several tests to avoid regressions. The source code is marked with thousands issues already fixed so I will have a lot of work to test it. I think option 1 is the right one. Agreed. Created attachment 97469 [details]
Fix for xml.text module
This patch fix the problems for XML in general as well for ANT files. In this fix the the attribute value is always overwritten when you pick up an option using CC. For example, <... option="|abc"/> and you pick up the option 'false' from cc the result will be <... option="false|"/>.
Created attachment 97470 [details]
Fix for xml.schema.completion module
This patch fix the problems for XML which use schemas, as persistence XML for example. In this fix has a little bit different behaviour, the value is overwritten just when you pick up an option using CC and the previous text is selected or the caret is after typed text. When the caret is before the previous typed characters, those you remain. For example, <... option="|abc"/> and you pick up the option 'false' from cc the result will be <... option="false|abc"/>.
Well, I hope I was clear about the behaviours in both file types. I choose this approach to avoid regressions in current implementations and implement schema based cc as ant script is too risky for now. BTW, both implementation cover what is requested in this issue (replace the selected value) so I consider it fixed. Comment on attachment 97469 [details]
Fix for xml.text module
I've just found out an issue in this patch. I will replace this patch soon.
Created attachment 97495 [details]
Proposed patch to fix xml.text
Well, it fix the first patch. The behaviour now is exactly the same as for schema. I found an use case where is desired to keep the characters previously typed: ant properties completion. The following scenario is valid:
<... file="${|**/*.java"/> when you call cc and choose the choose the option ${basedir} for example the desired behaviour is <...file="${basedir}|**/*.java"/> instead file="${basedir}|"/>. BTW, for completions like <option="f|"/> the behaviour is <option="false|"/> where false is the selected cc option and as well now selection is completely replaced as requested.
Any chance to see this integrated HR? I tested the patch and it works like a charm. Sergey, can your team review and integrate this patch ASAP? Thanks a lot! Alex, please review the patch and if it's ok apply it. I'll review proposed patches ASAP and integrate them into the trunk repository on Monday (Apr, 19th). I've checked the patch for xml.text. Please, attach an XML and XSD files which you use for making the patch for xml.schema.completion and/or describe a scenario for exact reproducing of this bug. Alex please see my comment #3 for the exact scenario. Thanks! Fixed in trunk: http://hg.netbeans.org/main/rev/8e647fc563c3 Thanks a lot Alex for your review and integration and special thanks to Michel for you patch! Integrated into 'main-golden', will be available in build *201004210200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/8e647fc563c3 User: Alex Petrov <alexpetrov@netbeans.org> Log: Fix for issue [#173691]. XML autocompletion doesn't override highlighted text. There is more to it. XML auto-complete is still badly broken. Attribute names (not values) are left in a mangled state when using auto-complete. I will attach screen shots. Also sometimes the auto-complete offers no suggestions at all when it should. Created attachment 100908 [details]
Editor just prior to finishing code completion
Created attachment 100909 [details]
Editor just after finishing code completion
My screen shots were taken with the 6.9 release on Windows XP. Michel, any chance you could review this bug fix? Yes, I will review this new scenario and try to propose a new patch for this. Thanks swpalmer for new details, I will investigate this soon and ask you if I need more details. I need to know which kind of XML are you editing, is it based on schema? I ask this because there are a implementation for some kind of file (Ant, schema, DTD etc). I can't reproduce your issue. Could you send me a xsd and xml sample about your problem? Which NB version are you using exactly? Thanks Could more info be added to this? I wish to fix it if I can reproduce it. Regards Scott, can you please answer Michel's questions? I tried it in the NetBeans 6.9.1 build #201007282301 and everything worked fine for me. I'm told by my coworker, "Yes, it still sucks. Start typing the attribute name, then use the auto complete and it fills in the whole name (eg. desdescription)" The XML is based on a schema, we have added the schema to the user catalog. It is just as bad or worse than before. We have seen a few different behaviours... In addition to the quoted issue above: If you start typing an attribute name then hit ctrol-space nothing is offered as a completion. If you type a space the whole list of attributes is offered automatically as completions. (If you choose one the cursor should be left between the quotes but it isn't) Closing an element doesn't out-dent the closing tag. Scott, this is not helpful unfortunately. We need to know what NetBeans IDE are you and your colleague using. Is it NetBeans IDE 7.0 development build #201010190000 or is it NetBeans IDE 6.9.1 or only 6.9? Can you attach the not working XML and XSD files here? Thanks for your cooperation! We are using NetBeans 6.9.1 Are you really having difficulty reproducing this? I have yet to see it work properly. I will soon attach two files... "plugin.xsd" - go to Tools-> DTDs and XML Schemas and add this to the User Catalog by selecting "System ID" entering :plugin.xsd" for the system ID then browsing to the file to fill in the URI "plugin.xml" - open this file in the editor and try to edit it.. see what it suggests for elements an attributes. See how it behaves when you type part of an attribute. See how it formats the document when it auto-completes the closing tag for an element. In nearly every case it fails to do what I would expect. files coming in a few seconds... Created attachment 102568 [details]
sample XML for use with plugin.xsd
Created attachment 102569 [details]
Schema for plugin.xml
Thanks Scott. I will try to address this next week if time permits. Regards It would also be nice when I select New File -> XML -> XML Document ...-> XML Schema-Constrained Document -> ??? why can't I pick from the schemas I have added to the User Catalog? If I enter "plugin.xsd" in the Schema field of the New File wizard it won't take (reverts to empty field). If I choose "Browse" it expects the Schema to be contained in my project if I browse "By File", if I browse "By Namespace" it is empty. (In reply to comment #42) > It would also be nice when I select New File -> XML -> XML Document ...-> XML > Schema-Constrained Document -> ??? why can't I pick from the schemas I have > added to the User Catalog? If I enter "plugin.xsd" in the Schema field of the > New File wizard it won't take (reverts to empty field). If I choose "Browse" > it expects the Schema to be contained in my project if I browse "By File", if I > browse "By Namespace" it is empty. Scott, please file another issue about it and CC me. Maybe I can try to do this in the future, or another NetFIXer, but for now I would like to do my best about this problem at code completion and mark this as FIXED again :) Thanks, I've entered Bug 191271 Report from old NetBeans version. Due to code changes since it was reported likely not reproducible now. Feel free to reopen if happens in 8.0.2 or 8.1. |