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 199695

Summary: caret-begin-line jumps to start of document
Product: editor Reporter: matthies <matthies>
Component: Painting & PrintingAssignee: Miloslav Metelka <mmetelka>
Status: RESOLVED FIXED    
Severity: normal CC: riggerthegeek, serggt1
Priority: P3 Keywords: REGRESSION
Version: 7.0   
Hardware: PC   
OS: Windows XP   
Issue Type: DEFECT Exception Reporter:

Description matthies 2011-06-25 16:34:24 UTC
When executing the following macro

    select-identifier copy-to-clipboard caret-backward "if (" caret-end-line ") throw new IllegalArgumentException(\"" paste-from-clipboard ": \" + " paste-from-clipboard ");" caret-begin-line caret-next-word caret-next-word caret-next-word

the caret ends up at the start of the document.
This does not happen when the caret-begin-line command is removed from the macro.

This is a regression, it was working correctly up to NB 6.9.

The macro's purpose is to turn an identifier "foo" into

    if (foo) throw new IllegalArgumentException("foo: " + foo);

The "caret-begin-line caret-next-word caret-next-word caret-next-word" should move the caret to after the "foo" within the conditional, so that a condition can be typed for "foo" (e.g. " < 0").
Comment 1 Svata Dedic 2011-09-09 11:48:42 UTC
Hm; it seems that it is caused by Editor thinking that the atomic operation is lengthy (# of modifications within atomic lock exceeded some threshold).

If inside "lengthy" operation, the DocumentOp starts to answer isActive() == false, which IMHO leads to an incorrect behaviour of viewToModelChecked: returns 0 for any coordinates and subsequently any mapping of coordinates > offset fails.

So either viewModelToChecked should report proper char index, or editor Utilities.getRowStart should avoid offset > rectangle > offset re-mapping.

If you have other suggestion, feel free to reassign back - thanks.
Comment 2 Quality Engineering 2011-09-23 13:23:53 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/efa1d8c49b70
User: Miloslav Metelka <mmetelka@netbeans.org>
Log: #199695 - caret-begin-line jumps to start of document - partial fix.
Comment 3 Svata Dedic 2011-10-10 12:25:28 UTC
*** Bug 196638 has been marked as a duplicate of this bug. ***
Comment 4 Svata Dedic 2011-10-10 12:45:24 UTC
*** Bug 193485 has been marked as a duplicate of this bug. ***
Comment 5 David Strupl 2012-11-01 09:14:43 UTC
I think this was fixed by Mila as the comment indicate.