Skip to content
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

Typing "<" gets encoded as <S-lt> #134

Closed
equalsraf opened this issue Jun 2, 2016 · 5 comments
Closed

Typing "<" gets encoded as <S-lt> #134

equalsraf opened this issue Jun 2, 2016 · 5 comments
Labels
input Keyboard or other input events

Comments

@equalsraf
Copy link
Owner

equalsraf commented Jun 2, 2016

Reported by @khalidchawtany. In Mac OS X US layout < is inserted by typing Shift+, but instead of getting <lt> neovim receives a <S-lt>. This happens because in input.c we remove the SHIFT modifier later in the function i.e.

  1. Removal of SHIFT happens after < is processed
  2. < is handled twice, one time as part of the specialKeys and another as a special escape case, and this case needs to be handled before either
  3. Presumably this could also happen in layouts where \ is the result of pressing shift and another key

Its a bit strange that on a Mac Qt reports this event key: < with modifier Shift and text: <

Tentative patch

diff --git a/src/gui/input.cpp b/src/gui/input.cpp
index b517c4b..97cb019 100644
--- a/src/gui/input.cpp
+++ b/src/gui/input.cpp
@@ -150,6 +150,10 @@ QString InputConv::convertMouse(Qt::MouseButton bt, QEvent::Type type, Qt::Keybo
  */
 QString InputConv::convertKey(const QString& text, int k, Qt::KeyboardModifiers mod)
 {
+       if (text == "<" || k == Qt::Key_Less) {
+               mod &= ~ShiftModifier;
+       }
+
        if (specialKeys.contains(k)) {
                return QString("<%1%2>").arg(modPrefix(mod)).arg(specialKeys.value(k));
        }
@lambdalisue
Copy link
Contributor

I had same issue on #160.

Interestingly, my environment is a bit different from what mentioned above.

OS: Ubuntu 16.04 Gnome desktop 64bit
Neovim: NVIM v0.1.5-634-g0595da8
Keyboard: 109 JP layout

I tested several keys but only < does not work correctly.

"/" 47 QFlags<Qt::KeyboardModifiers>(NoModifier) "/"
"/" 47 QFlags<Qt::KeyboardModifiers>(NoModifier) "/"
"/" 47 QFlags<Qt::KeyboardModifiers>(NoModifier) "/"
"\u001B" 16777216 QFlags<Qt::KeyboardModifiers>(NoModifier) "<Esc>"
"?" 63 QFlags<Qt::KeyboardModifiers>(ShiftModifier) "?"
"?" 63 QFlags<Qt::KeyboardModifiers>(ShiftModifier) "?"
"?" 63 QFlags<Qt::KeyboardModifiers>(ShiftModifier) "?"
"\\" 92 QFlags<Qt::KeyboardModifiers>(NoModifier) "<Bslash>"
"\\" 92 QFlags<Qt::KeyboardModifiers>(NoModifier) "<Bslash>"
"\\" 92 QFlags<Qt::KeyboardModifiers>(NoModifier) "<Bslash>"
"_" 95 QFlags<Qt::KeyboardModifiers>(ShiftModifier) "_"
"_" 95 QFlags<Qt::KeyboardModifiers>(ShiftModifier) "_"
"_" 95 QFlags<Qt::KeyboardModifiers>(ShiftModifier) "_"
"<" 60 QFlags<Qt::KeyboardModifiers>(ShiftModifier) "<S-lt>"
"<" 60 QFlags<Qt::KeyboardModifiers>(ShiftModifier) "<S-lt>"
"<" 60 QFlags<Qt::KeyboardModifiers>(ShiftModifier) "<S-lt>"
"," 44 QFlags<Qt::KeyboardModifiers>(NoModifier) ","
"," 44 QFlags<Qt::KeyboardModifiers>(NoModifier) ","
"," 44 QFlags<Qt::KeyboardModifiers>(NoModifier) ","
">" 62 QFlags<Qt::KeyboardModifiers>(ShiftModifier) ">"
">" 62 QFlags<Qt::KeyboardModifiers>(ShiftModifier) ">"
">" 62 QFlags<Qt::KeyboardModifiers>(ShiftModifier) ">"

lambdalisue added a commit to lambdalisue/neovim-qt that referenced this issue Jul 20, 2016
@equalsraf equalsraf removed the mac label Jul 20, 2016
lambdalisue added a commit to lambdalisue/neovim-qt that referenced this issue Jul 20, 2016
@lambdalisue lambdalisue mentioned this issue Jul 20, 2016
lambdalisue added a commit to lambdalisue/neovim-qt that referenced this issue Sep 19, 2016
lambdalisue added a commit to lambdalisue/neovim-qt that referenced this issue Sep 27, 2016
@equalsraf equalsraf added the input Keyboard or other input events label Jul 25, 2018
@eyalk5
Copy link

eyalk5 commented Dec 3, 2019

I have quite a new version of nvim-qt, and it happens(two month ago probably).

It prevents me from typing < on leaderF.

(I don't know how to check the version BTW).

@lambdalisue
Copy link
Contributor

#162 fixed issue at that time. The changes is small so migrate it by yourself to make a new PR. I'm OK that someone take my PR over.

@eyalk5
Copy link

eyalk5 commented Dec 8, 2019

Well, this patch is already incorporated into the master of neovim-qt. Just not directly.
The issue persists. And I couldn't find a way to encode "<" in a way that it wouldn't interpret this as the opening clause of a special command. This issue need to be dealt with in another place.

@jgehrig
Copy link
Collaborator

jgehrig commented Jul 31, 2020

This issue is resolved in the Pull Request above. It is available in v0.2.16

Marking as closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
input Keyboard or other input events
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants