Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 337313

Summary: Content Proposal only activated by the second key stroke
Product: [RT] RAP Reporter: Moritz Post <mpost>
Component: JFaceAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: tbuschto
Version: 1.4   
Target Milestone: 1.5 M5   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 330461    
Attachments:
Description Flags
Entry point to reproduce it none

Description Moritz Post CLA 2011-02-16 09:15:44 EST
When using the content proposal API to create content assist, the assist is only activated on the second key stroke. In RCP it reacts to the first char. That might be related to the fieldassist API.
Comment 1 Ivan Furnadjiev CLA 2011-02-18 08:50:19 EST
Created attachment 189272 [details]
Entry point to reproduce it
Comment 2 Ivan Furnadjiev CLA 2011-02-18 09:28:01 EST
The actual problem is the wrong (different from RCP) value of "position" parameter of IContentProposalProvider#getProposals method. When you type the first character, the "position" parameter is 1 in RCP, but 0 in RAP. The attached snippet returns empty array with proposals if "position" is 0. ContentProposalAdapter is heavy use Key Events. The proposals shell is auto activated on KeyDown event if autoActivationCharacters are set or on Modify Event if they are not set. Because key events are fired before setting the text caret position we get wrong (previous) caret position. For now, the workaround is to *NOT* set the autoActivationCharacters.
Comment 3 Tim Buschtoens CLA 2012-01-18 06:11:20 EST
Fixed in CVS HEAD.

The more general underlying problem was that key events are send before they are processed by the client, so widgets influenced by the key event dont have a chance to update. Fixed by sending the request asynchronously (i.e. with a timeout of 0 ms). My reasearch showed that even if the timer is started on keydown, it wont trigger until after the following keypress event.