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

Bug 315894

Summary: non composable key combinations erases first char in text editors
Product: [Eclipse Project] Platform Reporter: Henrik Lindberg <henrik.lindberg>
Component: SWTAssignee: Scott Kovatch <skovatch>
Status: RESOLVED FIXED QA Contact: Silenio Quarti <Silenio_Quarti>
Severity: normal    
Priority: P3 CC: daniel_megert, eclipse.felipe, skovatch, thomas
Version: 3.6Flags: Silenio_Quarti: review+
Target Milestone: 3.6.1   
Hardware: PC   
OS: Mac OS X   
Whiteboard:
Attachments:
Description Flags
Fix none

Description Henrik Lindberg CLA 2010-06-05 21:27:42 EDT
On a mac entering characters via composition (i.e. a character like combination of ~ and n, to produce ñ) works fine for combinations that produce a combined char, but for non existing combinations, the first entered character is instead erased.

This happens in editors, but not in fields in dialogs.

Reproducible: Always.
Reproduce by:
- Open a text editor (I tested in Java, as well as in Xtext generated editors):
- Type ~
- Type =

Result, the ~ is deleted. Expected result: "~="

Work around: Type '~' then <space> or <esc> to exit compose mode, then type '='.

The issue is quite irritating as eclipse editors work differently than the standard on the mac.
Comment 1 Dani Megert CLA 2010-06-07 06:02:22 EDT
Works for me using 3.6 RC4 on Windows XP and Linux GTK. Didn't test on Mac.
Comment 2 Thomas Hallgren CLA 2010-06-07 10:31:04 EDT
I'm using a Swedish keyboard and I see different behavior on Linux and Windows. On Linux, a composed character is created when I type ~ followed by = (the tilde is above the equal sign). On windows this doesn't happen.

If I switch to US keyboard on Linux, this behavior is gone.

So my conclusion is that it is not just related to what platform you're on. It's also locale dependent.
Comment 3 Dani Megert CLA 2010-06-07 10:34:12 EDT
I used a Swiss German keyboard.
Comment 4 Felipe Heidrich CLA 2010-06-07 10:45:12 EDT
what build are you running ?
Comment 5 Scott Kovatch CLA 2010-06-07 12:16:06 EDT
(In reply to comment #0)
> Reproducible: Always.
> Reproduce by:
> - Open a text editor (I tested in Java, as well as in Xtext generated editors):
> - Type ~
> - Type =
> 
> Result, the ~ is deleted. Expected result: "~="

What keyboard layout are you using? With the layouts I've tried (US, Spanish, Swiss German) I see a different behavior that's still wrong, but not as described:

- Switch to the Spanish layout
- Type option - ';', which gives the tilde and puts the editor in composition mode
- Type =

For Swiss German, you still type option-N to get a tilde, but the behavior is otherwise identical.

Result: Composition mode ends and the cursor is located after the ~. The = keystroke is lost. Compare to TextEdit, which cancels composition mode and inserts the '='.
Comment 6 Dani Megert CLA 2010-06-08 02:48:20 EDT
>Result: Composition mode ends and the cursor is located after the ~. The =
>keystroke is lost. 
I have a Swiss German keyboard and use Swiss German layout and there it works as expected i.e. the result is: ~=
Comment 7 Henrik Lindberg CLA 2010-06-08 10:30:16 EDT
I have a Swedish MacBookPro Keyboard.
Comment 8 Henrik Lindberg CLA 2010-06-08 19:37:39 EDT
Restating the problem:
In text editors eclipse deletes a compose sequence that should result in two separate characters.

Another sequence that fails is:
¨ (diaeresis) followed by 1

That ought to trigger the problem irrespective of keyboard layout as I don't think there exists a language that has a digit with diaeresis.
Comment 9 Thomas Hallgren CLA 2010-06-09 00:48:05 EDT
So if you type diaresis followed by a one, you get the one? On Linux I get nothing at all (everywhere, not just Eclipse).
Comment 10 Henrik Lindberg CLA 2010-06-09 07:07:05 EDT
(In reply to comment #9)
> So if you type diaresis followed by a one, you get the one? On Linux I get
> nothing at all (everywhere, not just Eclipse).

No, 'diaeresis' followed by '1' produces a 'diaeresis' followed by a '1' (i.e. *both* characters) on a mac - everywhere except in Eclipse text editors.

The issue is that text editors does not follow the platform policy (at least not on mac :))
Comment 11 Scott Kovatch CLA 2010-06-09 12:38:22 EDT
(In reply to comment #10)
> 
> No, 'diaeresis' followed by '1' produces a 'diaeresis' followed by a '1' (i.e.
> *both* characters) on a mac - everywhere except in Eclipse text editors.
> 
> The issue is that text editors does not follow the platform policy (at least
> not on mac :))

Okay, now I've got it. You're describing the same behavior as I wrote up in comment #5. I don't see the behavior of the first character after the dead key being deleted; it's just ignored. It's still a bug, but I want to make sure we're in agreement on what bug we're describing here. :-)
Comment 12 Scott Kovatch CLA 2010-06-09 13:15:39 EDT
For what it's worth, AWT text input on the Mac for Swing has the same bug.
Comment 13 Scott Kovatch CLA 2010-06-09 19:45:31 EDT
I now know what's going on but I'm not sure how to fix it. 

Normally Control.insertText is called once per keystroke but in this scenario it gets called twice: once to insert the diaeresis, and once to insert the '1'. The first time through Control.insertText(), s.keyInputHappened is set to true. On the second call to insertText we skip generation of KeyDown events because keyInputHappened was checked a few lines above.

I need to look into why insertText needs to be checking this field. It should definitely set it, but I'm not sure it needs to be testing it.
Comment 14 Scott Kovatch CLA 2010-06-09 20:02:30 EDT
Created attachment 171593 [details]
Fix

In insertText, don't check for keyInputHappened before sending events. That field is a stop-gap in the event view.interpretKeyEvents() didn't generate anything.
Comment 15 Scott Kovatch CLA 2010-06-28 13:04:25 EDT
Silenio, please review for 3.6.1.
Comment 16 Silenio Quarti CLA 2010-07-05 17:29:33 EDT
Looks good.
Comment 17 Scott Kovatch CLA 2010-07-06 12:25:36 EDT
Fixed in HEAD and 3.6 branch > 20100706.