Bug 35034 - Caret lags with 1.4.2 JVM
Caret lags with 1.4.2 JVM
Status: RESOLVED FIXED
Product: editor
Classification: Unclassified
Component: -- Other --
3.x
PC Windows ME/2000
: P3 with 1 vote (vote)
: 4.x
Assigned To: Miloslav Metelka
issues@editor
fix-in-41
: API_REVIEW_FAST
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2003-07-21 22:12 UTC by cahrens
Modified: 2007-11-05 13:44 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
:


Attachments
Diff of the fix (37.63 KB, patch)
2005-03-24 16:19 UTC, Miloslav Metelka
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description cahrens 2003-07-21 22:12:13 UTC
I notice that with the 1.4.2 JVM, the caret lags about a 
character behind when I type quickly.  Also, if I hold 
down the back key, the caret is one character behind (so 
empty space shows between the text and the caret as I 
delete).

The problem is not evident with 1.4.1.

It also does not seem to exist if I make the following 
modification in org\netbeans\editor\BaseCaret.java--

on line 426 uncomment the commented out line

Utilities.runInEventDispatchThread(

and comment out the following line

SwingUtilities.invokeLater(

However, the note above the code indicates that this was 
put in to fix a different problem.  It seems that with the 
1.4.2 JVM calling invokeLater causes the code to be 
executed too late, causing the Editor to appear to be 
slow.  

Here is the whole block of code in question, as my line 
numbers may be off--

/* part of fix of #18860 - Using runInEventDispatchThread
() in AWT thread
         * means that the code is executed immediately 
which can lead
         * to problems once the insert/remove in document 
is performed
         * because the update() uses views to find out the 
visual position
         * and if the views doc listener is added AFTER 
the caret's listener
         * then the views are not updated yet. Using 
SwingUtilities.invokeLater()
         * should solve the problem although the view 
extent could flip
         * once the extent would be explicitely scrolled 
to area that does
         * not cover the caret's rectangle. It needs to be 
tested
         * so that it does not happen.
         */
        Utilities.runInEventDispatchThread(
   //     SwingUtilities.invokeLater(
            new Runnable() {
                public void run() {
                    JTextComponent c2 = component;
                    if (c2 != null) {
                        BaseDocument doc = 
Utilities.getDocument(c2);
                        if (doc != null) {
                            doc.readLock();
                            try {
                               // update(c2.getBounds(), 
scrollPolicy);
                                update(scrollRect, 
scrollPolicy);
                            } finally {
                                doc.readUnlock();
                            }
                        }
                    }

                }
            }
        );
Comment 1 Miloslav Metelka 2004-01-23 13:27:04 UTC
Although I understand the reason for the original fix I think that we
should be able to improve the behavior into 3.6.
Comment 2 Miloslav Metelka 2004-11-01 12:13:47 UTC
I have an idea how this could finally be fixed. The problem clearly is
the document listeners ordering - the caret needs modelToView() to
position itself but views (that are also listening on document like
the caret does) may be fired later which causes that the caret finds
the original views state.
 The solution could be to state an ordering for document listeners
i.e. make several "layers" of document listeners with defined ordering
of firing the listeners of the particular layers. I'll try to make a
sketch of how this solution.
Comment 3 Roman Strobl 2005-03-11 12:28:47 UTC
Can we fix this issue in 4.1? If not, please remove the status whiteboard I've
added. Thanks.
Comment 4 Miloslav Metelka 2005-03-18 13:29:56 UTC
I'll attempt to fix it now into 4.1.
Comment 5 Miloslav Metelka 2005-03-24 16:18:48 UTC
I have a fix for the issue. As the fix adds a backward compatible change in
friend API of editor/util module I'm asking DevRev for fasttrack review. The
tests were created and apichanges.xml is updated accordingly.
Comment 6 Miloslav Metelka 2005-03-24 16:19:24 UTC
Created attachment 21112 [details]
Diff of the fix
Comment 7 Miloslav Metelka 2005-03-31 14:50:29 UTC
Fixed in main trunk:
Checking in fold/src/org/netbeans/modules/editor/fold/FoldHierarchyExecution.java;
/cvs/editor/fold/src/org/netbeans/modules/editor/fold/FoldHierarchyExecution.java,v
 <--  FoldHierarchyExecution.java
new revision: 1.6; previous revision: 1.5
done
Checking in libsrc/org/netbeans/editor/BaseCaret.java;
/cvs/editor/libsrc/org/netbeans/editor/BaseCaret.java,v  <--  BaseCaret.java
new revision: 1.109; previous revision: 1.108
done
Checking in libsrc/org/netbeans/editor/BaseDocument.java;
/cvs/editor/libsrc/org/netbeans/editor/BaseDocument.java,v  <--  BaseDocument.java
new revision: 1.119; previous revision: 1.118
done
Checking in util/manifest.mf;
/cvs/editor/util/manifest.mf,v  <--  manifest.mf
new revision: 1.6; previous revision: 1.5
done
Checking in util/api/apichanges.xml;
/cvs/editor/util/api/apichanges.xml,v  <--  apichanges.xml
new revision: 1.2; previous revision: 1.1
done
RCS file:
/cvs/editor/util/src/org/netbeans/lib/editor/util/PriorityListenerList.java,v
done
Checking in util/src/org/netbeans/lib/editor/util/PriorityListenerList.java;
/cvs/editor/util/src/org/netbeans/lib/editor/util/PriorityListenerList.java,v 
<--  PriorityListenerList.java
initial revision: 1.1
done
RCS file:
/cvs/editor/util/src/org/netbeans/lib/editor/util/swing/DocumentListenerPriority.java,v
done
Checking in
util/src/org/netbeans/lib/editor/util/swing/DocumentListenerPriority.java;
/cvs/editor/util/src/org/netbeans/lib/editor/util/swing/DocumentListenerPriority.java,v
 <--  DocumentListenerPriority.java
initial revision: 1.1
done
RCS file:
/cvs/editor/util/src/org/netbeans/lib/editor/util/swing/DocumentUtilities.java,v
done
Checking in util/src/org/netbeans/lib/editor/util/swing/DocumentUtilities.java;
/cvs/editor/util/src/org/netbeans/lib/editor/util/swing/DocumentUtilities.java,v
 <--  DocumentUtilities.java
initial revision: 1.1
done
RCS file:
/cvs/editor/util/src/org/netbeans/lib/editor/util/swing/PriorityDocumentListenerList.java,v
done
Checking in
util/src/org/netbeans/lib/editor/util/swing/PriorityDocumentListenerList.java;
/cvs/editor/util/src/org/netbeans/lib/editor/util/swing/PriorityDocumentListenerList.java,v
 <--  PriorityDocumentListenerList.java
initial revision: 1.1
done
Checking in util/test/cfg-unit.xml;
/cvs/editor/util/test/cfg-unit.xml,v  <--  cfg-unit.xml
new revision: 1.3; previous revision: 1.2
done
RCS file:
/cvs/editor/util/test/unit/src/org/netbeans/lib/editor/util/PriorityListenerListTest.java,v
done
Checking in
util/test/unit/src/org/netbeans/lib/editor/util/PriorityListenerListTest.java;
/cvs/editor/util/test/unit/src/org/netbeans/lib/editor/util/PriorityListenerListTest.java,v
 <--  PriorityListenerListTest.java
initial revision: 1.1


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo