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 99153 - Code reformat moves annotations to first line
Summary: Code reformat moves annotations to first line
Status: CLOSED FIXED
Alias: None
Product: ruby
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Torbjorn Norbye
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-27 15:52 UTC by Tomas Danek
Modified: 2007-07-03 14:42 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Danek 2007-03-27 15:52:43 UTC
NetBeans IDE Dev (Build 070327)
1.6.0-rc; Java HotSpot(TM) Client VM 1.6.0-rc-b99
Windows XP version 5.1 running on x86
en_US (nb); Cp1252
+ fresh build of ruby1 cluster
---------------------------------------------
have code some code, put somewhere breakpoint, and invoke C-S-f. Breakpoint is
moved to first line (just in editor, not in breakpoints window).
Comment 1 Martin Krauskopf 2007-03-27 15:55:49 UTC
Not sure if this is bug in debugger or reformatting. Seems to me that during
reformatting all source-code is removed and then readded again. If so, should
behave atomically?
Comment 2 Torbjorn Norbye 2007-03-27 17:57:36 UTC
Right now the formatting replaces the entire document with a reformatted version.

It could be improved in two ways:
(1) Only replace the middle section of the document that has been replaced. This means comparing 
from the beginning and the end of the document the old content versus the new content, and only 
replacing that part.  This is easy, and will work for not only reindenting a document but fully 
reformatting (pretty printing) it.  However, it will not correctly handle breakpoints in the changed 
section.

(2) When we are only reindenting (not actually reformatting) a document, rather than replace the whole 
document, go and adjust every single line with inserts and deletes to adjust the whitespace. Since this 
is done at line granularity, I suspect annotation positions will be preserved.  This is a bit more work 
(because the formatter currently just builds up a new document buffer in a StringBuilder and does a 
single replace; it would now have to compute effective offsets in the document as it's mutating it).

I might start with (1) (because it's easy) and leave the issue open until I address (2).
Comment 3 Torbjorn Norbye 2007-04-03 08:08:59 UTC
This should be fixed now; I've implemented approach #2 which seems to work well
Comment 4 Martin Krauskopf 2007-04-03 08:47:55 UTC
Yup, breakpoints keep theirs positions. Thanks. v/c
Comment 5 Jiri Kovalsky 2007-07-03 14:11:50 UTC
Reassigning this issue to newly created 'ruby' component.
Comment 6 Jiri Kovalsky 2007-07-03 14:42:57 UTC
Changing target milestone of all resolved Ruby issues from TBD to 6.0 Beta 1 build.