Bug 96059 - [content assist] Closing parethesis deleted by code assist
Summary: [content assist] Closing parethesis deleted by code assist
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.1   Edit
Hardware: All All
: P2 normal (vote)
Target Milestone: 3.1.1   Edit
Assignee: JDT-Text-Inbox CLA Friend
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-19 23:56 EDT by Billy Biggs CLA Friend
Modified: 2005-09-02 11:32 EDT (History)
3 users (show)

See Also:


Attachments
jdt-ui.diff (2.28 KB, patch)
2005-08-04 08:37 EDT, Tom Hofmann CLA Friend
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Billy Biggs CLA Friend 2005-05-19 23:56:24 EDT
In a Java editor, I find that whenever I go to type:

  Table table = new Table(shell, SWT.NONE);

I end up with:

  Table table = new Table(shell, SWT.NONE;

What happens is that hitting ';' seems to cancel the completion, and deletes the
closing parenthesis in the process.  This is really annoying for me, since I am
a fast typer and often find it faster to type the full text in rather than
select the first match.  Here are the exact steps to reproduce:

1. On a new line:
    Table table = new Table(shell, SWT.
2. Wait for the code assist drop-down to appear.
3. Type "NONE)".
4. Note that the code assist drop-down is still visible.
5. Hit ";".  The ")" is now replaced by a ";", leaving:
    Table table = new Table(shell, SWT.NONE;
Comment 1 Dani Megert CLA Friend 2005-05-20 04:40:56 EDT
Works for me. What are your settings?

Tom, can you reproduce?
Comment 2 Tom Hofmann CLA Friend 2005-05-20 05:57:01 EDT
can reproduce. 

- parentheses closing must be on
-> during step 1, the closing parenthesis is inserted

- smart semicolon setting does not matter

The problem seems to be that the proposal popup is not dismissed upon typing
')'. Then the semicolon somehow gets replaced by some typing smartness... 

Disposing the popup with 'Esc' and then typing ';' works as expected. 
Comment 3 Tom Hofmann CLA Friend 2005-05-26 13:26:14 EDT
we should investigate a fix for RC2
Comment 4 Tom Hofmann CLA Friend 2005-06-08 06:32:22 EDT
The proposal shell should already hide when you type in the closing parenthesis.

The problem is that the parenthesis is already in the document from the
auto-closing feature. Now typing it does not modify the document, but only the
caret is moved behind the parenthesis. Since no modification happens,
ICompletionProposal.validate is not called. 

In fact CompletionProposalPopup does not get involved at all when the caret is
changed programmatically. There really is no way to detect the caret change as
the SelectionListener on StyledText does not fire changes as long as the
selection has no length.

A possible workaround on our side is to validate proposals before they are
inserted. Currently, proposals are validated when the selection is changed by
using the arrow keys, or when the document is modified, but not before insertion.
Comment 5 Dani Megert CLA Friend 2005-06-08 09:54:00 EDT
Deferred. Fix is too risky at this time.
Comment 6 Dani Megert CLA Friend 2005-06-08 09:54:47 EDT
Not a regression from 3.0.
Hint: you can disable auto-closing of parenthesis to avoid this, or: use code
assist instead of typing yourself ;-)
Comment 7 Douglas Pollock CLA Friend 2005-07-06 16:42:13 EDT
I curse you Billy.  All of 3.1, I didn't see this bug at all.  (Confirmed: I do
see this same problem in 3.0.2.)  Then you mention the bug, 3.1 ships, and now
this bug is driving me up the wall.


Comment 8 Dani Megert CLA Friend 2005-07-07 02:36:01 EDT
Doug, check your settings. You probably changed them
Comment 9 Tom Hofmann CLA Friend 2005-07-07 04:16:14 EDT
Note that increasing the auto-assist delay will make this better somewhat, as
you won't get automatic code assist as much.
Comment 10 Dani Megert CLA Friend 2005-07-07 04:28:35 EDT
Marking as potential 3.1.1 candidate. Final decision depends how the fix looks like.
Comment 11 Douglas Pollock CLA Friend 2005-07-07 10:07:38 EDT
I don't think I changed any settings related to the editors in quite some time.
 Which setting in particular do you feel I should check?
Comment 12 Dani Megert CLA Friend 2005-07-07 11:07:52 EDT
auto-closing of parenthesis 
Comment 13 Douglas Pollock CLA Friend 2005-07-07 11:17:44 EDT
I believe the preference Dani is talking about is: Java > Editor > Typing >
Automatically close ... (Parentheses), [square] and <angle> brackets.

In my workspace, I believe it is still at its default setting (i.e., checked). 
I don't recall ever having changed this setting, and restoring defaults does not
change it.
Comment 14 Tom Hofmann CLA Friend 2005-07-25 06:14:19 EDT
I released a fix to HEAD.

Port to 3.1.1 will have to wait for the review.
Comment 15 Dani Megert CLA Friend 2005-08-04 07:02:18 EDT
Tom, can you attach a patch against 3.1.
Comment 16 Tom Hofmann CLA Friend 2005-08-04 08:37:49 EDT
Created attachment 25664 [details]
jdt-ui.diff

Patch against R3_1 of jdt-ui, fixing the problem by revalidating the proposals
before applying them.
Comment 17 Dani Megert CLA Friend 2005-08-05 10:31:14 EDT
Patch is good for 3.1.1.
Committed fix to R3.1.1.
Comment 18 Dirk Baeumer CLA Friend 2005-08-09 05:47:42 EDT
Start verifying...
Comment 19 Dirk Baeumer CLA Friend 2005-08-09 05:58:43 EDT
Can't be verified yet since patch isn't in M20050804-1200. Got released 0805. I
tested it in M20050804-1200 and the problem is still in.
Comment 20 Dirk Baeumer CLA Friend 2005-09-02 10:53:41 EDT
Start verifying again...
Comment 21 Dirk Baeumer CLA Friend 2005-09-02 11:32:51 EDT
Verified on M20050831-1200 plus plug-in export.