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.
Expanding any template defined in Tools > Options > Editor options > Code templates > Language = XML while editing an XML Scheme in source view causes the cursor to be repositioned at line 1, column 1. I have classified this as a P2 based on the guidelines at http://qa.netbeans.org/bugzilla/bug_priority_guidelines.html on the basis of: 1. usability: Critical usability problem 2. doesn't work, workarround exists: the editor itself is perfectly functional and has good code completion support Test case: 1. File > New > XML Schema 2. Switch to source view 3. Enter "cl" and press expansion shortcut (I am using Tab but the behavior is the same for other key combinations) Environment details: Product Version: NetBeans IDE 6.1 (Build 200804211638) Java: 1.6.0_04; Java HotSpot(TM) Client VM 10.0-b19 System: Windows XP version 5.1 running on x86; Cp1252; en_GB (nb) Userdir: C:\Documents and Settings\MLEdwards\.netbeans\6.1 Plugin details: Version: 1.2 Source: deadlock ( http://deadlock.netbeans.org/hudson/job/javadoc-nbms/lastSuccessfulBuild/artifact/nbbuild/nbms/updates.xml.gz)
Visible problem, will try to fix it for M1.
Browsing through the xml code-base, it seems like it just relies on the core editor template framework. Kindly take a look. If you think the problem is in my code, please assign it back to me.
Cursor is repositioned by the XMLLexerFormatter.reformat(...) method which is called at the end of the template insertion. Reassigning back.
Fix in issue 132586 will fix this one as well. *** This issue has been marked as a duplicate of 132586 ***
while working on the fix for issue 132586, i realized, this may not actually be a duplicate of that. For the other issue, I position the caret where it was before the formatting, so someone else is repositioning to line1, col1 in replacing code template.
dbalek, can you pl. take a look. I'm actually positioning the caret to where it was before.
I don't think that it is a good practice to do reformat using doc.replace(0, doc.getLength(), formattedDoc.getText(0, formattedDoc.getLength()), null); If there were any marks in the reformatted document implemented using javax.swing.text.Position objects (like bookmarks, code template parameter regions, etc.), all of these marks would be moved to position 0 after reformat. Better approach would be to compute diffs between doc and foramttedDoc and apply only these diffs. This would preserve all Position markers to stay on proper places. Reassigning back.
Fixed changeset bd8460d637b8 in main details: http://hg.netbeans.org/main?cmd=changeset;node=bd8460d637b8
Integrated into 'main-golden', available in build *200807300201* on http://bits.netbeans.org/dev/nightly/ Changeset: http://hg.netbeans.org/main/rev/bd8460d637b8 User: sonali@netbeans.org Log: Fix for issue#135297 XML template expansion doesn't preserve cursor position.
Verified Product Version: NetBeans IDE Dev (Build 200808010201) Java: 1.5.0_13; Java HotSpot(TM) Client VM 1.5.0_13-119 System: Mac OS X version 10.5.4 running on i386; MacRoman; en_US (nb)
*** Issue 147262 has been marked as a duplicate of this issue. ***