Alexey-T / CudaText

Cross-platform text editor, written in Free Pascal
Mozilla Public License 2.0
2.54k stars 173 forks source link

[Qt5] Cannot type accented letters when autocomplete popup is open #5002

Closed pintassilgo closed 1 year ago

pintassilgo commented 1 year ago
  1. Launch CudaText Qt5.
  2. Install "Complete From Text" (just to make things easier, but the issue is also reproducible with any autocomplete like LSP or acp).
  3. Make sure you're using a keyboard layout that has accent key as dead key, which when followed by a letter produces an accented letter.
  4. Type padr pad, so that autocomplete will show up suggesting padr.
  5. While autocomplete popup is visible, type the combination to insert any accented letter. Like ~ + a to produce ã, or ´ + e to insert é...

Result: the letter is inserted without the accent, like pada or pade instead of padã and padé.

Natively accented key doesn't count on this issue, for instance my keyboard has the key Ç that is not affected by the issue. It must be a combination of dead key + letter.

This issue only happens when both conditions below are filled:

  1. You're using Qt5 build of CudaText.
  2. Autocomplete popup is open while you're trying to type the accented key.
Alexey-T commented 1 year ago

Test program for Qt5, linux-64. tst-KeyDown.zip

it shows hex codes of chars when you press them. please test with dead keys and tell me the - a) what it shows for normal accented keys? b) what it shows for dead keys?

Alexey-T commented 1 year ago

Updated test program: tst-KeyDown.zip

pintassilgo commented 1 year ago

It only shows non-accented keys, with the exception of Ç because, as I said, it's the only natively accented key of my keyboard. Other accented letters require a combination with dead keys and aren't recognized by this program.

So...

a) It doesn't show normal accented keys. i.e. when I press ~ followed by a, it shows nothing for ~ and shows just a after a.

b) Nothing.

This was with the first test program, I'll try now with the updated version.

pintassilgo commented 1 year ago

My keyboard layout (Portuguese, ABNTII) for reference

image

pintassilgo commented 1 year ago

With the updated program:

Same results, but now with keydown: # lines.

So if I press just A, it shows

keydown: 65
keypress: a, hex: 61

If I press ~ followed by A, which should produce ã, the output is the same:

keydown: 65
keypress: a, hex: 61

The program doesn't recognize keydown/keypress when I press ~ (or any dead key).

Alexey-T commented 1 year ago

Please aslo see https://wiki.freepascal.org/CudaText#Linux:_Keyboard_input_problems maybe you can adjust OS settings to fix it?

pintassilgo commented 1 year ago

Already tried that, unfortunately it doesn't work.

Actually, it doesn't make sense for me to be OS issue because typing accented letters always work on Cuda when autocomplete popup isn't open. So it should be something on how Cuda handles keyboard input when autocomplete popup is open.

pintassilgo commented 1 year ago

Just adding: typing accented letters work even on dialog text input, like Command palette.

The issue is when autocomplete popup is open and focus should be in editor, but it's probably in the autocomplete popup so that Cuda currently needs to pass the input to the editor, I guess. Similar to issues such as #5004.

pintassilgo commented 1 year ago

Maybe you could create an invisible text input when autocomplete popup is open to correctly intercept typed content and then pass it to editor?

Alexey-T commented 1 year ago

It would be ugly hack and ugly code in app... I won't do hidden fields

Alexey-T commented 1 year ago

If GTK2 version has this bug, I can understand why: ATSynEdit has GTK2 specifig IME code:

{$ifdef LCLGTK2}
{$ifdef GTK2_IME_CODE}
// fcitx IM
procedure TATSynEdit.WM_GTK_IM_COMPOSITION

For Qt5 , I don't know the reason of accent problem.

pintassilgo commented 1 year ago

This bug only affects Qt5.

pintassilgo commented 1 year ago
  • add: auto-completion window is now parented in the main window: 1) no more separate shadow, 2) main window don't loose focus and don't blink, 3) no more showing of autocomplete-window in Alt+Tab list (thanks d0vgan)

Reading this, I have a little hope it will cause focus to stay in editor instead of switching to autocomplete popup so that maaaybe this issue is fixed, supposing Cuda no longer needs to pass key inputs from autocomplete popup to editor, which I believe is somehow the cause of the issue. Could you please provide a qt5 build for me to test?

Alexey-T commented 1 year ago

Sure, cudatext-q.zip

pintassilgo commented 1 year ago

Yes! It was fixed! Thanks.