Skip to content

r181 Ctrl key mappings no longer work like they did on r180 (r180 fresh install on new MBP) #1569

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

Closed
4 of 7 tasks
dond1bru opened this issue Mar 8, 2025 · 5 comments · Fixed by #1571
Closed
4 of 7 tasks
Labels
Milestone

Comments

@dond1bru
Copy link

dond1bru commented Mar 8, 2025

Steps to reproduce

Enter key strokes Ctrl+5 while in Normal or Insert mode.

Using simple macOS 15.1.1 Shortcuts App's "Text Action" mapped to Settings > Keyboard > Keyboard Shortcuts > Services > Shortcuts: ^5 (Control 5) or ^U (Control u) or Control "other key".

Using native macOS Shortcuts App for text insertion & key mapping is a low latency, low maintenance, low overhead & low cost, solution compaired to TextExpander, Espanso or other. The additional capabilities of something like Jenkins is not needed. I use this is MarkDown documents & also source code.

Expected behaviour

Clipboard text is "pasted" into the active MacVim window.

Given a patch may take a while, what other options do I have? I use this capability 100's of times a day.
Can I mod .vimrc to mitigate? (preferred solution pre patch)
Can I revert to r180 to mitigate?

Any help is much appreciated.

Version of Vim and architecture

Vim version 9.1.1128

Environment

MBP 14" M4 Nov 2024 running macOS 15.1.1
Terminal > Default macOS, Version 2.14 (455)
Value of $Term > xterm-256color
Shell > Default macOS, zsh 5.9 (arm64-apple-darwin24.0)

macOS 15.1.1 Shortcuts App's "Text" Action mapped to Settings > Keyboard > Keyboard Shortcuts > Services > Shortcuts: ^5 (Control 5) or ^U (Control u) or Control "other key".
The MdH5 (MarkDown Header 5) Shortcut (^5) simply inserts text & ToD like, "##### @ 15:13 ".
This works on this GitHub "issue" form, Apple Apps & in Terminal VIM v9.1.1128.
Other Ctrl key mapping do similar or like ^U run AppleScripts via Shortcuts App's "Run AppleScript" Action like inserting browser URL & web page title e.g., "[] [Issues · macvim-dev/macvim] [] (https://github.com/macvim-dev/ macvim/issues)."

How MacVim was installed

Nov 16, 2024 disk image https://macvim.org/ https://objects.githubusercontent.com/github-production-release-asset-2e65be/5641441/

Logs and stack traces

Vim configuration where issue is reproducable

No response

Issue has been tested with given configuration

  • by running MacVim.app from GUI macOS interface
  • by running vim/gvim/etc installed by MacVim
  • by running other versions of vim (e.g. /usr/bin/vim)

Issue has been tested with no configuration

  • by running mvim --clean (or gvim, supplied by MacVim distribution)
  • by running vim --clean (in terminal, supplied by MacVim distribution)
  • by running vim --clean (in terminal, other suppliers, e.g. /usr/bin/vim)

Other conditions

  • The both Homebrew packages "vim" and "macvim" are installed
@ychin
Copy link
Member

ychin commented Mar 11, 2025

Sorry I read this over and I am still not sure how to reproduce this. Can you share the actual Shortcut? My understanding here is you have some custom macOS Shortcuts that are bound to Ctrl-5 but it no longer works? Can you show me (using the Share command) what exactly the Shortcut is doing? Can you also show me how you are binding your shortcut for Ctrl-5?

As in, please have concrete steps that someone can follow from step 1 and have a complete reproduction, including how to create the Shortcut (e.g. how does "MdH5" work?), what exactly doesn't work, etc.

Some other questions:

  • Are you sure this is caused by r181?
  • Also, have you tried just accessing the action directly in MacVim -> Services (instead of through the Ctrl-5 hotkey)?

@ychin
Copy link
Member

ychin commented Mar 19, 2025

Hi @dond1bru do you have an update? Just want to see how I can reproduce this issue.

@ychin ychin added the Response Needed Issues / PRs marked with this will be automatically closed in 45 days unless it receives an update label Mar 19, 2025
@dond1bru
Copy link
Author

Attached are screenshots of the two Shortcuts described above.

Image Image

Control key mapping created in Shortcuts but also shows up in Settings > Keyboard > Keyboard Shortcuts > Services > Shortcuts.....
Image

@ychin ychin removed the Response Needed Issues / PRs marked with this will be automatically closed in 45 days unless it receives an update label Mar 21, 2025
@ychin
Copy link
Member

ychin commented Mar 27, 2025

Ok I can reproduce this issue. Thanks for the screenshots!

It's probably related to the Apple Intelligence Writing Tools / text input fixes in #1552. I'll take a look. If you need it now, you can downgrade to r180 first, but I'll see if I can fix this and deploy and r181.1 update soon-ish since I want to push a pre-release build anyway.

@ychin ychin added the Bug label Mar 27, 2025
@ychin ychin added this to the Release 182 milestone Mar 27, 2025
ychin added a commit to ychin/macvim that referenced this issue Mar 28, 2025
Interactions with OS services that insert texts were improved in macvim-dev#1552
to make it work in a more integrated fashion instead of a hacky
injection of 's' followed by the text. However, it only accounted for
services that replaces selected texts in visual mode. In other modes,
MacVim would simply ignore the service. This was a regression as
previously it would work everywhere (albeit often times in non-intuitive
manner since if used in insert mode the user would see an 's' in the
beginning). This also affects Shortcuts that a user may have made that
could be invoked from the Services menu or bound to a hotkey.

Fix this properly by allowing this to be used in Normal / Insert /
Cmdline modes in addition to Insert mode.

Even with this fix, there is still a slight difference between the
new behavior and the old hacky solution - the old method would leave the
user in Insert mode, wehreas the new method would stay in the original
mode. I think this is an improvement so no need to fix.

Fix macvim-dev#1569.
@ychin
Copy link
Member

ychin commented Mar 28, 2025

#1571 will fix this issue. I'll try to push out a pre-release build in a week or so.

In r181, your Shortcut actually still works but it only works when there's text selected in Visual Mode, whereas previously it would work in Normal and other modes too. This fix will make it work in those other modes too. Note that there's still a slight change in behavior. The previous kind-of broken behavior in r180 was that if you press the shortcut in Normal mode, it would replace the character under the cursor (if there is one) and leave you in Insert mode afterwards. The new behavior would just insert the text without replacing any text (unless you were already selecting some texts in visual mode) and leave you back in Normal mode which I think is the desired behavior.

If you want this fix and don't want to stay in r180, you could update to the pre-release build once it's out. You can either download it directly from the website or go to MacVim settings and allow pre-release software updates under "Advanced". Or you could build MacVim yourself.

I can remind you again when the build is out. (Edit: the pre-release is out now)

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

Successfully merging a pull request may close this issue.

2 participants