Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 332485 - [content assist] Suggest overwrites what I type if I press Enter too fast
Summary: [content assist] Suggest overwrites what I type if I press Enter too fast
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.7 M6   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-13 18:53 EST by Stepan Koltsov CLA
Modified: 2011-02-15 10:04 EST (History)
2 users (show)

See Also:


Attachments
Fix (4.61 KB, patch)
2011-02-14 13:54 EST, Markus Keller CLA
daniel_megert: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stepan Koltsov CLA 2010-12-13 18:53:20 EST
Build Identifier: 20100917-0705

Eclipse completion overwrites what I type if I press Enter too fast.

Reproducible: Sometimes

Steps to Reproduce:
* Open Java file.

* import org.junit.Assert (for example)

* Type "Assert.assEq"

* Press Cmd-Space to get list of completion

* Choose assertEquals(double, double)

* Eclipse paste "Assert.assertEquals(expected, actual). "expected" word is hightlighted (selected). Eclipse also shows suggest with options "expected" and "0": http://screencast.com/t/ZmhXbUb1n

* Type "1" (or any other value) AS FAST AS YOU CAN and press "Enter" to go to the next method parameter.

* If you pressed "Enter" fast enough, Eclipse deletes what you just typed and paste "expected" word back.


Screencast:

http://screencast.com/t/TbuOxKahDwW

Bug is very annoying, because it forces me too type slowly.
Comment 1 Dani Megert CLA 2010-12-14 09:52:36 EST
Markus and I could very rarely reproduce the problem. Would have to dig into the code or get more precise steps.
Comment 2 Markus Keller CLA 2010-12-15 13:39:21 EST
Steps in HEAD:
- set a breakpoint in ParameterGuessingProposal#apply(..) at line 155 before "ui.enter();" with condition:
    Thread.sleep(5000);
    return false;

- in the runtime workbench, have this method:
	void foo() {
		java.util.Collections.copy
	}

- set caret after "copy"
- without undue delays, press Ctrl+Space, 1, Enter

=> was:
		java.util.Collections.copy(dest, src)
... with linked field "src" selected and proposals popup visible

=> expected (same as when you wait until proposal is completely inserted):
		java.util.Collections.copy(1, src)
... with caret after ")" and linked mode terminated


(In reply to comment #0)
> * Type "1" (or any other value) AS FAST AS YOU CAN and press "Enter" to go to
> the next method parameter.

Note that Enter normally does *not* take you to the next argument position after you've typed the first argument. The Enter key only does that if the current linked position has multiple proposals and shows a proposals list. If the list is hidden, Enter takes you to the exit position. The Tab key takes you to the next linked field, and I couldn't reproduce a problem when using Tab.

So, we're left with only one bug when pressing "1, Enter" very quickly:
Pressing "1" doesn't immediately close the filters list (see the asyncExec(..) in CompletionProposalPopup2#filterProposals()), and if the "Enter" key is processed too quickly, the original proposals are still available and the first proposal replaces the "1" that had been typed just before.

Solution:

When I remove the asyncExec in filterProposals(), then I can't reproduce the problem any more.

Dani, I'm not sure if we really need that asyncExec. For this scenario, it should be removed, but maybe we need to keep it for cases where the document is changed in a non-UI thread (but AFAIK, that would cause a lot of trouble in other parts of the editor).
Comment 3 Markus Keller CLA 2011-02-14 13:54:41 EST
Created attachment 188931 [details]
Fix

> When I remove the asyncExec in filterProposals(), then I can't reproduce the
> problem any more.

The asyncExec delays filtering and keeps the UI responsive for fast typers, so we should keep it.

However, when the user types Enter, we need to make sure we process the outstanding filtering request and only apply proposals that fit the current document state. If no proposals are left, we should go to the exit position.

I've been running with this patch in my runtime workbench for a while now, and I'm confident it's the right solution. Dani, please speak up if you don't like the fix.
Comment 4 Dani Megert CLA 2011-02-15 09:57:15 EST
Comment on attachment 188931 [details]
Fix

+1 for the patch.
Comment 5 Markus Keller CLA 2011-02-15 10:04:23 EST
Fixed in HEAD.