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

CMD + SHIFT mappings are inconsistent #25068

Closed
fredizzimo opened this issue Sep 9, 2023 · 3 comments · Fixed by #27316
Closed

CMD + SHIFT mappings are inconsistent #25068

fredizzimo opened this issue Sep 9, 2023 · 3 comments · Fixed by #27316
Labels
bug issues reporting wrong behavior complexity:low Low-risk, self-contained. Do NOT ask "can I work on this", just read CONTRIBUTING.md mappings key bindings

Comments

@fredizzimo
Copy link
Contributor

fredizzimo commented Sep 9, 2023

Problem

CMD + SHIFT mappings behave differently from other mappings like ALT + SHIFT and are not normalized to a standard format. The reason seems to be this line, which I have found no explanation for

if (!(modifiers & MOD_MASK_CMD) && !(modifiers & MOD_MASK_CTRL)) {

This also makes mappings between different Neovim GUIs inconsistent, since each of them reports the mappings slightly differently to Neovim.

NOTE: I'm aware that the CTRL mappings behaves differently due to legacy reasons, and it's also clear why the CTRL condition is there. But not why the condition is there for CMD.

Steps to reproduce

  1. Create a file mappings.vim with the following contents
map <D-a> <cmd>:echomsg "D-a"<cr>
map <D-A> <cmd>:echomsg "D-A"<cr>
map <D-S-a> <cmd>:echomsg "D-S-a"<cr>
map <D-S-A> <cmd>:echomsg "D-S-A"<cr>

map <M-a> <cmd>:echomsg "M-a"<cr>
map <M-A> <cmd>:echomsg "M-A"<cr>
map <M-S-a> <cmd>:echomsg "M-S-a"<cr>
map <M-S-A> <cmd>:echomsg "M-S-A"<cr>

map <C-a> <cmd>:echomsg "C-a"<cr>
map <C-A> <cmd>:echomsg "C-A"<cr>
map <C-S-a> <cmd>:echomsg "C-S-a"<cr>
map <C-S-A> <cmd>:echomsg "C-S-A"<cr>

call feedkeys("\<D-a>")
call feedkeys("\<D-A>")
call feedkeys("\<D-S-a>")
call feedkeys("\<D-S-A>")

call feedkeys("\<M-a>")
call feedkeys("\<M-A>")
call feedkeys("\<M-S-a>")
call feedkeys("\<M-S-A>")

call feedkeys("\<C-a>")
call feedkeys("\<C-A>")
call feedkeys("\<C-S-a>")
call feedkeys("\<C-S-A>")
  1. Run nvim --clean -u mappings.vim
  2. Type :messages
  3. Observe that the following output was generated
D-a
D-A
D-S-a
D-S-A
M-a
M-S-A
M-S-A
M-S-A
C-A
C-A
C-S-A
C-S-A

Expected behavior

The output should be:

D-a
D-S-A
D-S-A
D-S-A
M-a
M-S-A
M-S-A
M-S-A
C-A
C-A
C-S-A
C-S-A

Making the D and M mappings consistent, and select the last shift combination that was mapped.

Neovim version (nvim -v)

NVIM v0.9.2

Vim (not Nvim) behaves the same?

N/A

Operating system/version

Arch Linux (WSL)

Terminal name/version

Windows Terminal

$TERM environment variable

xterm-256color

Installation

pacman

@fredizzimo fredizzimo added the bug issues reporting wrong behavior label Sep 9, 2023
@zeertzjq zeertzjq added the complexity:low Low-risk, self-contained. Do NOT ask "can I work on this", just read CONTRIBUTING.md label Sep 9, 2023
@matu3ba

This comment was marked as off-topic.

@mitchellh

This comment was marked as off-topic.

@fredizzimo

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issues reporting wrong behavior complexity:low Low-risk, self-contained. Do NOT ask "can I work on this", just read CONTRIBUTING.md mappings key bindings
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants