Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 337156 - [content assist] steals my semicolon when I press ; outside of linked mode
Summary: [content assist] steals my semicolon when I press ; outside of linked mode
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.7 M6   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 154740 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-02-14 14:09 EST by Markus Keller CLA
Modified: 2011-02-22 02:05 EST (History)
2 users (show)

See Also:


Attachments
Fix (2.48 KB, patch)
2011-02-14 14:28 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 Markus Keller CLA 2011-02-14 14:09:37 EST
N20110213-2000

package xy;
class Bug {
    void foo() {
        set
    }
    
    void setAnswer(boolean answer, int n) { }
    boolean getAnswer() {
        return true;
    }
}


- Have "Java Editor > Content Assist > Insert best guessed arguments" selected and "Java Editor > Typing > Auto-insert Semicolon" unchecked

- invoke content assist after "set"
- press Enter to accept first proposal
- press End
- press ;
=> line is "setAnswer(;|, 0)" where | is the caret

Expected: Semicolon should be inserted at end of line where the caret was.
Comment 1 Markus Keller CLA 2011-02-14 14:28:06 EST
Created attachment 188938 [details]
Fix

Dani please speak up if you don't like the fix.

I've removed an "if (key == ';')" check in the language-agnostic CompletionProposalPopup2 that was there for no good reason, and I changed the additional trigger character in ParameterGuesser from ';' to ',', which also fixes bug 154740.
Comment 2 Dani Megert CLA 2011-02-15 09:02:51 EST
*** Bug 154740 has been marked as a duplicate of this bug. ***
Comment 3 Dani Megert CLA 2011-02-15 09:05:57 EST
Comment on attachment 188938 [details]
Fix

+1 for the fix.
Comment 4 Markus Keller CLA 2011-02-15 09:12:50 EST
Fixed in HEAD.
Comment 5 Dani Megert CLA 2011-02-21 05:58:54 EST
Actually, the fix breaks an important scenario:
1. take example from comment 0 and remove the second argument from setAnswer
2. code complete after "set"
3. press ';'
==> semicolon replaces the selection instead of adding it at the end.
Comment 6 Markus Keller CLA 2011-02-21 10:36:23 EST
(In reply to comment #5)
Yeah, that's what you used to get for free, but it's actually another scenario that was broken. With "Auto-insert Semicolon" unchecked, typing ";" should just mean "replace the selection with a ;". And that's what we do in HEAD.

To get the semicolon at the end, you need to enable the preference.
Comment 7 Dani Megert CLA 2011-02-22 02:05:41 EST
(In reply to comment #6)
> (In reply to comment #5)
> Yeah, that's what you used to get for free, but it's actually another scenario
> that was broken. With "Auto-insert Semicolon" unchecked, typing ";" should just
> mean "replace the selection with a ;". And that's what we do in HEAD.
> 
> To get the semicolon at the end, you need to enable the preference.

Indeed. I'm so used that the semicolon is auto-inserted that I forgot about this in my new test workspace.