-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ctrl-[ no longer behaves as Esc on Czech keyboard on Windows (it worked in g/vim 8) #12595
Comments
map <F8> <C-[>
imap <F8> <C-[>
map <F9> <C-]>
imap <F9> <C-]> Best regards, |
...oops... |
@tonymec My problem is not how to get The problem is that it has changed on Windows recently. I cannot say if it was with vim 9 or earlier (issues here suggest it might have been in vim 8) as I have been using my vim 8 (on Windows) for several years without an update. What I can say however is that in very same Windows and using very same (Czech) layout, when I connect to linux terminal (using putty and XTERM emulation) and run So my keyboard did not change, the handling in the OS did not change, and my assumption is that Windows still emits the Now some observations about the new vim and gVim on Windows:
For me it looks like vim/gVim implementation is not only inconsistent with the behavior of its linux counterpart (run in linux terminal), but is even producing different (wrong) results when run in graphical form or console form ( |
FWIW: |
There was a big change in handling of key events in 8.2.4807, and after that there were several patches related to this.
There might be still some issues in some keyboard layouts. |
@k-takata I have been a long time programmer (though I know nothing about vim implementation) and trying to find some fixes for each keyboard localization individually does not seem like a right way to do it - especially since before it worked for all layouts. What do you suggest I can do about it? |
I think we need to modify this part: Lines 2164 to 2175 in e7d9ca2
I don't know the virtual key codes and the scan codes for the keys that cause the issue in Czech keyboards, though. |
@k-takata
I do not know if the author uses a different (from English) keyboard layout and faced some issues when mapping For people used to the English layout, defining a key press as Now for the Czech layout (at least as defined by Windows, and I would expect the other layouts using the similar approach), the key press This may get confusing because some Ctrl combos actually got localized by the key character. The Czech layout is What I am trying to say here is that there is some logic (at least in Windows) in how the layouts are localized, it is not just a mechanical translation of characters and key modifiers, and we cannot simply ignore that, or try to outsmart the system by "stripping that information and translating the keys differently". |
I believe it can seem even weirder for Cyrillic and other non-Latin keyboards, but it isn't strange at all when you get used to it. When in 'Cyrillic', e.g. Russian layout, pressing In fact it's so inconvenient, that I had to return to Vim 8.2. Yes I known that Vim is another world and I do use its features, including |
@sme-prus001 I do not think it is strange at all. In fact, I believe that Microsoft actually did a pretty good job when localizing the keyboard layouts to "less than trivial clones of English one". What I still do not understand what was the problem with the key handling the controversial PR was trying to fix. Right now it seems it has broken every non-standard layout (in Czech case it is even broken differently in Windows console and in GUI). @k-takata I do not know who is the authority over Windows integration on this project, but I would suggest to roll back the change then discuss the problems the original PR was addressing and see how it should be solved correctly. |
The same here. The problem seems to be that developers insist on "let's fix bugs one by one" approach, which in this case makes related bugs resurface in a vicious circle (despite being "closed").
Well, I did:
instead, which kind of works. |
I do not believe it is possible as "fixing" it would basically mean either reimplement the complete localization logic for every layout possible, or go back to trusting the system that it knows what it si doing (and rolling back the change). |
Just a tip for anyone interested in seeing the issue clearly:
|
@brammool, @mattn, @LemonBoy, @ant0sha, @tonymec, @vim-ml, @vds2212, @ychin, @zewpo, @k-takata, @chrisbra, @sme-prus001, @ladayaroslav When reading the comments on the PR #10155, the corresponding commit, and the follow-up fixes, I collected the list of people I am trying to reach by this shout-out out of desperation. I apologize to anyone who may feel being addressed wrongly, in that case please ignore the rest. First I would like to get on the same page with When seeing It does not however mean that the key pressed together with For those who wonder, why I would not want to use the same key which writes the particular character, Now, what Windows does right is that it uses this important distinction extensively when defining localized keyboard layouts. So they define (on the Czech layout) If you finger type (with 10 fingers), typing But not only on Windows. I checked on friend’s Mac with MacOS and Vim 9 in terminal, and the Czech keyboard layout works there as expected - it honors localized On Lubuntu (with the recent install and Vim 9) not sure whether Lubuntu (KDE?) Czech keyboard localization or Vim are wrong but I have to type When reading the comments on different threads these got my attention: from @ant0sha (#11831 (comment))
Which basically expresses my feeling about the whole affair, apart from the part about the “tuning”. This “tuning” is actually the layout localization implemented by the OS according to the principles I described above. from @ant0sha (#11831 (comment))
I am not sure if UNIX world means Linux world, but if it does, the way Linux (or some Linux GUIs?) are handling the localization is questionable at best (as per my example with the Czech layout and getting to The question we should be asking however is, why cannot Vim just honor a localized layout on each platform as it did before the controversial patch? For the record: At the moment, the graphical Vim (gVim) and the console Vim are broken in two different ways on Czech layout, i.e. pressing The proposed way forward, if I understand well the comment and the list of patches posted here by @k-takata, is that a user of a non standard (i.e. non-English) layout should reverse engineer his keyboard layout implemented by the OS and recreate its implementation for Vim because we can no longer use the OS for that? I am afraid that even if I wanted to do it for the Czech layout, I am not sure, I would not miss anything without actually writing some key translator and simulator and running all possible combinations through it, because I definitely do not use all possible control codes or other convoluted combinations. Plus there are several Czech layouts, so what to do with the others? And if I do not submit a correct patch, I am out of luck? (see 6 months old comment from @sme-prus001 at 77fc0b0#commitcomment-97542548 stating that the patch basically broke completely the control codes on Cyrillic layout) When it started to be clear that the patch had had no clue about how the localization works on Windows, why was it not rolled back? |
Good example. Exactly those mappings will not be possible any more if the handling of keyboard events in gvim will be reverted to the old state. And for those listed you perhaps would not care, but for other Russian letters it may be interesting. |
I'm pretty sure those (and the like) worked before the change. I.e. we need working |
I have to admit, such thoughts were also going in my head. But it was not my patch. And also, what stopped me that a lot of newly possible mappings will be get lost again, after existing for short time. So it is a (possible) trade off now between old broken shortcuts vs new broken shortcuts? |
@ladayaroslav: |
See here: #10615 (comment) And (for "which in this case makes related bugs resurface in a vicious circle (despite being "closed")") — this one is alive and well, again: #10579 |
I guess I am kind of a Linux guy, in a sense the Linux project is maintained. Its maxim is/was "never break a user land". If you do (accidentally) you get booted either by maintainers, or by Linus himself :). I guess in my view, breaking a keyboard layout on a text editor is such a deed. In fact I cannot see how one can do much worse than that. The idea that this could be considered an acceptable trade-off by anyone never crossed my mind. I guess that all the people involved in the patch (starting from the author and ending with the maintainer who checked it in) never used localized keyboard (a non-trivial one), or never used Ctrl codes on it, or never Anyway, I would consider the idea that we ditch the keyboard layout handling in the OS completely in order to get better control over it, to be a bold take on the subject, but only if the original keyboard layout is preserved. Not at the cost that any non-English layout is broken - and left to users to get fixed - which as I already also tried to explain - basically means reimplementing it for Vim. I do not see why anyone would want to do that, at least not in this ad-hoc way where people are guessing which keys should be used to emit the codes and even wanting to "harmonize" with flawed Linux scheme (sorry, if it sounds like I am picking at you, I am really not - it just happens your comment got my attention as an example of how "unguided" the whole affair was). |
One thing I realized I forgot and need to address directly (@ant0sha - again no hard feelings) reading this comment, in case this might be a common perception here: This is the reason why I believe there is no acceptable trade-off for this type of damage ("do not break the userland") and we should not be guessing which keys should emit which control codes as it is already well defined by the keyboard layout implemented by the OS. |
To untangle from this circumstances I am working now on making two GUI w32 input "methods" to configurably coexist, classic one (based on TranslateMessage() win API) and experimental (based on ToUnicode() win API) |
@ant0sha |
done |
Steps to reproduce
Using gVim on Windows (version 9.0.1664).
Pressing
Ctrl-[
(or FWIWCtrl-]
) no longer works as expected (asEsc
, orgoto tag
). It writes the Czech letters instead:Ctrl-[
writesú
,Ctrl-]
writes)
.which are the actual letters on the Czech layout at the corresponding keys.
I did not check other
Ctrl-<??>
combinations.Expected behaviour
I have found two similar issues already closed here: #11831, #10454
but since I am not familiar with Belgian layout, or behavior the Belgian users expect, I cannot really say if it concerns my case. But it definitely does not resolve it.
From what I read in those and some other threads about the
Ctrl
handling I assume there is a confusion among some people howCtrl-[
works on non English layouts. I will try to explain on the Czech layout on Windows.Note: For someone not familiar with Czech layouts, there are several "Czech" layouts with different degree of localization, but the one I will be talking about is the one named just
Czech
(the others are usually certain mix of English and Czech layout).On the Czech layout the key right to
P
(which on the English layout is the one with[
) has a Czech letterú
. The symbol[
is however written byAltGr+f
on the Czech layout. For English key]
(which is right to[
) the situation on the Czech keyboard is similar again - there is)
on Czech layout and]
is written byAltGr+g
.When Microsoft was localizing the keyboard they actually did a smart thing and did not map
Ctrl-[
toCtrl-AltGr-f
(as happened on some linux distros), but realized thatCtrl-[
is indeed a control code (and not an actual letter) and that the usability should be more important than formal correctness. We may say they did not localizeCtrl-[
by the character, but by the key (i.e. kept the same key in the layout regardless its localized character).I have been used to use
Ctrl-[
forEsc
and it worked in linux terminal, or Windows, regardless the keyboard layout for the past 30 years. The only dire cases were GUIs in some linux distros where they indeed expected users to writeCtrl-AltGr-f
.I am not sure what happened in g/Vim from ver 8 to ver 9, but it looks to me, like someone made an effort to actually break this behavior for some reason. I wonder what was the motivation and what is the proposed way forward?
Version of Vim
9.0.1664
Environment
Windows 10 Pro 64 bit,
gVim for Windows installed from https://github.com/vim/vim-win32-installer.
Logs and stack traces
No response
The text was updated successfully, but these errors were encountered: