PSReadLine icon indicating copy to clipboard operation
PSReadLine copied to clipboard

Cyrillic breaks CTRL+ combos

Open 243083df opened this issue 4 years ago • 16 comments
trafficstars

Environment

PS version: 7.1.4
PSReadline version: 2.1.0
os: 10.0.19041.1165 (WinBuild.160101.0800)
PS file version: 7.1.4.0
HostName: ConsoleHost
BufferWidth: 120
BufferHeight: 9001

Steps to reproduce

Open powershell 7.1.4 in windows terminal. In cyrillic keymap press CTRL+С (C cyrillic) CTRL not working and terminal show C CTRL+A and CTRL+C not working after it in both keymaps

There is also another cases but it hard to reproduce.

Expected behavior

Actual behavior

CTRL+C working correctly

243083df avatar Sep 17 '21 05:09 243083df

https://github.com/microsoft/terminal/issues/11232

243083df avatar Sep 17 '21 05:09 243083df

What keyboard layout are you using?

daxian-dbw avatar Sep 17 '21 15:09 daxian-dbw

Russian (Russia) https://docs.microsoft.com/en-us/globalization/keyboards/kbdru

243083df avatar Sep 19 '21 11:09 243083df

@iSazonov Are you able to reproduce this issue?

daxian-dbw avatar Sep 21 '21 17:09 daxian-dbw

No. The same PSRL 2.1.0 but PS 7.2: image

iSazonov avatar Sep 21 '21 17:09 iSazonov

Thank you @iSazonov! You were using the Russian Keyboard, right?

daxian-dbw avatar Sep 21 '21 18:09 daxian-dbw

I come back with mysterious addition. When open PS and CTRL+C(Cyrillic), PS react like Cyrillic C entered. And when do CTRL+C just add c, and CTRL+Ф add 'ф', but if i switch layout to ENG, and input a then a will be added, but when i press CTRL+A then PS treat A as russian ф

243083df avatar Sep 21 '21 19:09 243083df

Thank you @iSazonov! You were using the Russian Keyboard, right?

Yes, and I switched to Russian layout.

iSazonov avatar Sep 22 '21 08:09 iSazonov

Windows Terminal versionI I tested with is latest Preview 1.11.2421.

iSazonov avatar Sep 22 '21 15:09 iSazonov

@243083df Given that @iSazonov couldn't reproduce the issue using Russian Keyboard, we need more information on the repro steps. Can you be more specific on what keyboard you are using, what display language and default language, as well as what additional software you installed that you think may affect the language input on your machine?

daxian-dbw avatar Sep 23 '21 20:09 daxian-dbw

I debugged this problem and found what user32.dll works only with one locale with that it started. https://github.com/PowerShell/PSReadLine/blob/master/PSReadLine/Keys.cs#L150 Since if you start PSReadline and press english CTRL+any then ToUnicode always return english chars in chars. And if you (re)start PSReadline and press cyrillic CTRL+any, ToUnicode always return cyrillic chars in chars.

user32.dll has version 10.0.19041.1202

243083df avatar Sep 28 '21 18:09 243083df

Have this language settings

image

This for english

image

This for russian

image

243083df avatar Sep 28 '21 18:09 243083df

Bug wont reproduce on ubuntu 20.04 LTS under WSL2. Same PC.

243083df avatar Oct 11 '21 16:10 243083df

I am debug further and find out that https://github.com/PowerShell/PSReadLine/blob/master/PSReadLine/ReadLine.cs#L103 With ctrl return in KeyChar not ascii code, but alphabelic so CTRL+C become 3 '\u0003' and char.IsControl at https://github.com/PowerShell/PSReadLine/blob/master/PSReadLine/Keys.cs#L231 return true

Console.ReadKey(); return same result so seems thats it used to readkeys

243083df avatar Oct 11 '21 16:10 243083df

This is a duplicate of https://github.com/PowerShell/PSReadLine/issues/1393. You may also take a look at my previous attempt at fixing this, PR https://github.com/PowerShell/PSReadLine/pull/1848.

For the record, this still 100% reproduces for me using PowerShell 7.2 and any Windows Terminal (or conhost for that matter), on all of my Windows 10 and Windows 11 computers.

ForNeVeR avatar Nov 20 '21 14:11 ForNeVeR