Bug 219750 - [styled text] Typing ~~ inserts é~~
Summary: [styled text] Typing ~~ inserts é~~
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows All
: P3 normal (vote)
Target Milestone: 4.13 M3   Edit
Assignee: Pierre-Yves Bigourdan CLA
QA Contact: Niraj Modi CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 550059
  Show dependency tree
 
Reported: 2008-02-21 04:38 EST by Fedronic valere CLA
Modified: 2019-08-23 01:29 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fedronic valere CLA 2008-02-21 04:38:16 EST
Build ID: N/A

Steps To Reproduce:
1. Type ~~ (AltGr+é, AltGr+é) in a styledText (e.g text editor)

Expected:
~~
Actual :
é~~



More information:
Happens on windows with an azerty keyboard (FR)
Comment 1 Felipe Heidrich CLA 2008-02-26 14:57:42 EST
Verified, the problem happens for deadkeys in the ALT GR position.
In azerty FR that happens for AltGr+é and AltGr+è

In the US-Int deadkeys in the SHIFT position also have problems.
Input: SHIFT+6, SHIFT+6, e
result: ^^ê
expected: ^^e

Steve, I'll need your help to understand WM_CHAR/WM_KEY, etc
Comment 2 Pierre-Yves Bigourdan CLA 2019-04-06 05:41:11 EDT
This bug still happens in recent Eclipse releases. The most annoying character is probably the backquote ` (è`` is inserted instead), as it's heavily used in some programming languages and markdown files.
Comment 3 Eclipse Genie CLA 2019-06-21 16:48:07 EDT
New Gerrit change created: https://git.eclipse.org/r/144666
Comment 4 Pierre-Yves Bigourdan CLA 2019-06-21 16:49:44 EDT
I've spent a fair bit of time investigating these issues, and I've ended up digging in the Widget.java class, in particular the wmKeyDown method.

Here is the sequence of WM_KEYDOWN and WM_CHAR messages that I have observed when typing ~~ (AltGr+é, AltGr+é):
* holding AltGr sends multiple pairs of WM_KEYDOWN messages alternating between wParam 17 and 18. None of these messages send events downstream.
* when AltGr+é is combined for the first time, one WM_KEYDOWN message with wParam 50, corresponding to the é key. This one is ignored as the PeekMessage function indicates that there is a WM_DEADCHAR on the message queue. This sets display.lastDead to true.
* when AltGr+é is combined for the second time (the user releases 'é' and holds it down again), another WM_KEYDOWN message with wParam 50 is sent. This one isn't ignored as there is no more WM_DEADCHAR on the message queue. An event for character 'é' is sent to the StyledText widget.
* this second AltGr+é combination also triggers two consecutive WM_CHAR messages with messages with wParam 126. Two event for character '~' are sent to the StyledText widget.

My patch does the following: if last WM_KEYDOWN corresponded to a dead key, ignore the subsequent WM_KEYDOWN message and let the events be sent by WM_CHAR only.

I've tried this out both on FR and US-Int layouts, and it seems to solve all problems previously described in this bug, as well as several other issues I've been experiencing with the FR layout, for example: 
1. Type (AltGr+é, AltGr+é, space)
Expected:
'~~ '
Actual :
'é~~~' (no space and bogus third ~ in addition to the unwanted é)
2. Type (AltGr+é, AltGr+é, backspace)
Expected:
'~'
Actual :
'é' (both ~~ are deleted in one go)

Looking forward to getting some thoughts on this!
Comment 5 Andrey Loskutov CLA 2019-07-03 16:57:33 EDT
@SWT commiters: could anyone with Windows access please review the patch https://git.eclipse.org/r/144666?
Comment 6 Paul Pazderski CLA 2019-07-03 17:36:51 EDT
I'm not SWT experienced enough to review this change but I can test.
I could reproduce the described problem and the patch indeed fix it but I randomly found it break the following sequence:

AltGr+é, p, backspace

Expected: ~
Actual: ~p

The backspace (same for delete) key does nothing when pressed after dead key + regular letter. Same for e.g. AltGr+é and a = ã.



And a general hint for such bugs, it's a nice help to say what keys to press on a English labeled keyboard. I needed a moment to realize what AltGr+é means and would have it easier with 'Enable azerty layout and press AltGr+2 on English keyboard'
Comment 7 Pierre-Yves Bigourdan CLA 2019-07-06 14:04:40 EDT
Thanks for the feedback Paul. I've uploaded a new patch which should deal with the issues you described.
Comment 8 Paul Pazderski CLA 2019-07-08 12:59:20 EDT
(In reply to Pierre-Yves B. from comment #7)
> I've uploaded a new patch which should deal with the issues you described.

It does and I couldn't find a new problem.
Comment 9 Pierre-Yves Bigourdan CLA 2019-07-24 16:47:33 EDT
Thanks for testing Paul. Is someone available to take a closer look at the code change? It would be nice to get this through for 4.13M3.
Comment 10 Niraj Modi CLA 2019-07-25 07:12:56 EDT
(In reply to Pierre-Yves B. from comment #9)
> Thanks for testing Paul. Is someone available to take a closer look at the
> code change? It would be nice to get this through for 4.13M3.

Will take a look at this next week.
Comment 11 Niraj Modi CLA 2019-08-14 03:13:11 EDT
(In reply to Pierre-Yves B. from comment #9)
> Thanks for testing Paul. Is someone available to take a closer look at the
> code change? It would be nice to get this through for 4.13M3.

Hi Perrie,
Tested the patch, the situation is very much improved and problem is gone when I test with ~~ characters only.

Doing some further testing found one issue:
Tried out below key combination in quick succession and could notice é~~ getting inserted:
²&#&²#²~#²&#&~#&~#&~#&~#&é~~é~~é~~é~~é~~é~~é~~é~~é~~é~~é~~é~~é~~é~~

Note: These 4 keys are the top left key below the function line on my keyboard.
1. Press AltGr with my right hand in continuation.
2. With left hand press these 4 keys in sequence and then after some time only press ~ key
3. You will notice é~~ getting inserted. I have to repeat step 2-3 multiple times to reproduce the issue.
Comment 12 Pierre-Yves Bigourdan CLA 2019-08-14 05:57:20 EDT
Hello Niraj, thanks for reviewing and glad to hear that the situation has improved. I don't have access to a proper dev environnement in the next ten days or so, I'll look into the remaining issue when I'm back, though I'm concerned it may be tough to deliver for 4.13. If you or anyone else has ideas to improve the patch, do have a go at it! :)
Comment 13 Niraj Modi CLA 2019-08-14 06:03:53 EDT
(In reply to Pierre-Yves B. from comment #12)
> Hello Niraj, thanks for reviewing and glad to hear that the situation has
> improved. I don't have access to a proper dev environnement in the next ten
> days or so, I'll look into the remaining issue when I'm back, though I'm
> concerned it may be tough to deliver for 4.13. If you or anyone else has
> ideas to improve the patch, do have a go at it! :)

Am occupied with other bugs.
Ok, in that case I plan to push current patch into the master and will raise a new bug for the outstanding issue. Hope it's fine with you.
Comment 14 Pierre-Yves Bigourdan CLA 2019-08-14 06:07:33 EDT
(In reply to Niraj Modi from comment #13)
> (In reply to Pierre-Yves B. from comment #12)
> > Hello Niraj, thanks for reviewing and glad to hear that the situation has
> > improved. I don't have access to a proper dev environnement in the next ten
> > days or so, I'll look into the remaining issue when I'm back, though I'm
> > concerned it may be tough to deliver for 4.13. If you or anyone else has
> > ideas to improve the patch, do have a go at it! :)
> 
> Am occupied with other bugs.
> Ok, in that case I plan to push current patch into the master and will raise
> a new bug for the outstanding issue. Hope it's fine with you.

Sounds good, like that I can take a look at the improvement bug for 4.14.
Comment 16 Niraj Modi CLA 2019-08-14 06:30:23 EDT
(In reply to Eclipse Genie from comment #15)
> Gerrit change https://git.eclipse.org/r/144666 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=e68a42b079cb4a66deb813e36d6b80529014c633

Thanks Pierre for the bug fix, resolving now.
Raised bug 550059 for the outstanding issues of comment 11.
Comment 17 Niraj Modi CLA 2019-08-23 01:29:13 EDT
Verified in Build id: I20190821-1800 on Win7, Outstanding issues tracked via bug 550059.