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 160940

Summary: [67cat] Code-Completion/Hint processing erases editor text
Product: editor Reporter: esmithbss <esmithbss>
Component: Completion & TemplatesAssignee: Dusan Balek <dbalek>
Status: RESOLVED FIXED    
Severity: blocker CC: dstrupl, emononen, mmirilovic, mslama, pjiricka
Priority: P3    
Version: 6.x   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:
Attachments: Screen Shot of dialog window after 20 second wait for the dialog to refresh
Screenshot showing GUI just prior to text replacement

Description esmithbss 2009-03-23 19:22:37 UTC
While coding in Ruby, the code completion assistant popped up.  I continued typing and the code completion window
attempted to keep up with me, but was unable to do so.

When I completed my line and hit the return key, everything I had typed into the editor after the code completion popup
appeared vanished.

How to reproduce:

1) Create a project (I am using Ruby)
2) Open up/create a code file within the project which will require
   you to type in code.
3) Type in some code which will cause the popup to appear at some point.
4) Allow the pop-up to appear
5) Continue typing faster than the popup can keep up.  Include typing past what the system can match against the pop-up
contents.
    An (ruby) example would be:
      aValueString.each_byte do |i|
             (pause after the each until the pop-up appears)
6) As soon as you complete typing the line, hit the enter key.

At this time, the editor only contains up to, but not beyond the "each" when the pop-up appeared.
Comment 1 esmithbss 2009-03-23 19:38:55 UTC
This appears to be similar to my earlier bug that was closed as worksforme:
http://www.netbeans.org/issues/show_bug.cgi?id=151784

The difference is that in the earlier bug, the text was replaced with the wrong information.  In this bug, the text is
completely erased.

Comment 2 Dusan Balek 2009-03-23 21:11:40 UTC
Reassigning to Ruby.
Comment 3 esmithbss 2009-03-23 23:09:29 UTC
I've looked at the difference between how the pop-up behaves in Ruby projects and Java Projects.  Apparently, the dialog
in Java either works faster and vanishes once the method is "recognized".  The Ruby side doesn't parse/populate as fast
or vanish when you have typed beyond what the system recognizes.
Comment 4 Erno Mononen 2009-03-24 09:46:05 UTC
I'm probably not able to type fast enough to reproduce this:) I'll keep trying still.
Comment 5 esmithbss 2009-03-24 09:58:28 UTC
There seems to be a speed issue with the code-completion dialog under ruby.  See my additional report
http://www.netbeans.org/issues/show_bug.cgi?id=160975 for another issue with speed and synchronization using this component.

Comment 6 esmithbss 2009-04-06 01:52:26 UTC
Created attachment 79495 [details]
Screen Shot of dialog window after 20 second wait for the dialog to refresh
Comment 7 esmithbss 2009-04-06 01:55:35 UTC
To reproduce the state from associated screen capture:

1) Start from a clean file.

2) Begin Typing the line "ActionC"

3) Bring up the completion dialog

4) Type "::Base"

5) Type ".reset"

*** At this point, the dialog on my machine is out of sync with my typing and no longer refreshes.

6) Continue typing "_session"

7) Hit the Enter key.
Comment 8 Erno Mononen 2009-05-19 14:21:41 UTC
I'm sorry but I still can't reproduce this (not even with your steps). Can you reproduce this completely from scratch 
(with a new project)? 
Comment 9 Erno Mononen 2009-05-21 08:43:00 UTC
It seems to be that the bug must be in GsfCompletionProvider as it takes care of filtering the results; please evaluate 
the issue. I wasn't able to reproduce (hence the incomplete keyword), but the reporter confirmed via email that this 
happens to him all the time on different hardware configurations.
Comment 10 Erno Mononen 2009-05-25 13:11:30 UTC
I'm removing the incomplete keyword to get the bug evaluated by the editor team. For me this wasn't reproducible.
Comment 11 Vitezslav Stejskal 2009-05-27 15:17:59 UTC
If this is a speed issue, could you please use Profile Me! and attach here the profiler snapshot? Also please generate
several threaddumps in fast succession and attach them here. There is a wiki page describing how to do both threaddumps
and Profile Me! http://wiki.netbeans.org/GenerateThreadDump

Thanks
Comment 12 David Strupl 2009-06-08 14:07:56 UTC
Marek, these are yours now ...
Comment 13 mslama 2009-06-09 09:28:41 UTC
Are you able to reproduce with latest trunk dev build? With Java project (java source)? Or only with Ruby?
Comment 14 mslama 2009-06-09 10:23:44 UTC
Can you attach project where it is reproducible? I tried to create sample Ruby project and tried to simulate your use
case (in Depot Application I opened Models cart.rb, started to edit in
  def add_product(product)
    ActionController::Base.reset
but when I type re code completion disappears.)

There is also big difference in behavior when code completion dialog is invoked in auto mode or explicitly. From your
steps it looks like it is invoked explicitly. Is it right?
Comment 15 esmithbss 2009-06-12 07:57:30 UTC
Someone commented that the code-completion box is tied to the typing events.  In essence, when the code completion
dialogs are displayed, they are key aware.  Something I noticed in a test just now, is that the Ruby code completion
dialogs (and possibly others) are not tied to all of the relevant events.  Most specifically, all mouse clicks.

To reproduce what I just experienced:

In a Ruby On Rails application, do some typing and allow the system to bring up the code-completion dialogs.  Now move
the mouse cursor to the tab of the file you are currently editing and click the left mouse button.  The dialogs should
close, but they don't.

Click on the pull down list of currently open files.  The dialogs don't close.

This may signify a missing lose_focus handler somewhere which is exactly the missing behavior that (afaik) causes the
dialogs to process keystrokes when they are no longer relevant.
Comment 16 esmithbss 2009-06-14 07:17:15 UTC
Created attachment 83549 [details]
Screenshot showing GUI just prior to text replacement
Comment 17 esmithbss 2009-06-14 07:23:32 UTC
I just added another screenshot showing the behavior just prior to encountering this error.

What is happening is the system is taking an excessive (10 to 30+ seconds) time to load the code-completion dialogs. 
While it is populating the dialog I am able to continue typing (whether it shows on the screen or not) and as I type, I
go beyond what is valid for the code-completion dialog box to process (as can be seen by the garbage displayed here.

If, after I type all of the text and the code-completion dialog box appears, I hit the Enter key, everything I have
typed since the code-completion dialog started populating is replaced by the highlighted entry in the code-completion
dialog.  Any other key after the code-completion dialog appears results in only the dialogs being closed.

Typically, the long delays are caused when I manually invoke the code-completion dialog; however, the screenshot from
Jun 14th was generated by hitting the period ('.') key following the Event identifier.  (In this case, Event is a model
in my project).

Comment 18 Vitezslav Stejskal 2009-09-08 13:09:24 UTC
*** Issue 171563 has been marked as a duplicate of this issue. ***
Comment 19 mslama 2009-09-15 13:57:28 UTC
Dusan pls can you look at this?
Comment 20 Dusan Balek 2009-09-16 16:52:39 UTC
Infrastructure part fixed in jet-main. 'Please wait' should be displayed when code completion refresh is slow.
http://hg.netbeans.org/jet-main/rev/53b2f7536657

However, the main problem here is the code completion refresh is slow in Ruby editor. It seems that (under some
circumstances) the Ruby completion refuses to filter results (obtained on initial code completion invocation) when user
starts typing again.
Comment 21 Dusan Balek 2009-09-17 14:12:37 UTC
Finally, I'm able to reproduce the issue now.
Comment 22 Dusan Balek 2009-09-18 08:14:19 UTC
Fixed in jet-main.

http://hg.netbeans.org/jet-main/rev/4cc85ed698a9
Comment 23 Quality Engineering 2009-09-18 22:21:45 UTC
Integrated into 'main-golden', will be available in build *200909181401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/4cc85ed698a9
User: Dusan Balek <dbalek@netbeans.org>
Log: Issue #160940: Code-Completion/Hint processing erases editor text - fixed.