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 238282 - cold folding operations complete asynchronously on 7.4
Summary: cold folding operations complete asynchronously on 7.4
Status: RESOLVED INVALID
Alias: None
Product: editor
Classification: Unclassified
Component: Code folding (show other bugs)
Version: 7.4
Hardware: PC Windows XP
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords: REGRESSION
Depends on:
Blocks:
 
Reported: 2013-11-12 21:29 UTC by err
Modified: 2014-07-15 05:30 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
source code for trivial module to reproduce issue (7.03 KB, application/zip)
2013-11-12 21:29 UTC, err
Details

Note You need to log in before you can comment on or make changes to this bug.
Description err 2013-11-12 21:29:26 UTC
Created attachment 142108 [details]
source code for trivial module to reproduce issue

vim, and so jVi, has a different model for code folding commands. One
difference is that the caret does not move when collapse/expand folds.
I've attached trivial module source for reproducing the issue,
see below. For NB-7.2,7.3 the following works

    fh.render(new Runnable() {
        void run() {
            int dot = baseCaret.getDot();
            // close folds ...
            baseCaret.setDot(dot, false);
        }
    }

with NB-74 it fails, the caret gets moved to the beginning of the closed
fold. It looks like expand fold doesn't need to have the caret moved back
at all.

If I do the setDot with EventQueue.invokeLater then it works.
I'll make that change, probably qualified by version number so it only
applies to 7.4. I always wonder how/when it will break and what else might
get affected when this is the fix.

But I'm hoping you can illuminate me on the change and where to look in the
source code to understand it. This could save me considerable time tracking
it down to get a sense of how well (and for how long) the invokeLater fix
will work. And for the expand fold, will it be safe to leave out the
invokeLater? (I'll probably leave the setDot for the expand since that meets
my level of paranoia)

To reproduce:
With module installed, put cursor on some line in a fold, (not the first
line of the fold). Take note of the cursor line number in the status display.
Then Menu>Editor>CollapseFold, note that the line number has changed.
If you modify the source to use the invokeLater, line does not change.
Comment 1 Svata Dedic 2014-07-15 05:30:15 UTC
The code was restructured in 7.4. Even the original code posted some caret changes into SwingUtilities.invokeLater queue; it may be possible that with the new code, your FoldHierarchyListener comes earlier.
Are you 100% sure your FHListener runs in ED thread ?