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

Recursive mappings not working on two letter inputs with the same initial #3099

Open
2 tasks
Affonso-Gui opened this issue Mar 24, 2024 · 0 comments
Open
2 tasks

Comments

@Affonso-Gui
Copy link

Describe the bug
Recursive mappings don't work for some two letter inputs.

To Reproduce
Add the following mappings:

map gs V
map ga gs

Expected behavior
When pressing ga, the line-wise visual selection mode should start, but nothing happens.
(ga -> gs -> V).

Confirmed that vim 9.0 works as expected.

Environment:

First discovered the bug in the following environment, but also confirmed it on a clean source build in the VimApp and developer VS2022 instance.

  • Visual Studio version: 2019
  • VsVim version: 2.8.0.0
  • Programming Language: C++
  • Check(Type 'x') any that are installed:
    • ReSharper
    • Visual Assist

Additional context
The problem seems to be caused by trying to comply with the following vim specification (:help recursive_mapping)

If the {rhs} starts with {lhs}, the first character is not mapped again (this is Vi compatible). 
For example:
    :map ab abcd
will execute the "a" command and insert "bcd" in the text.  The "ab" in the {rhs} will not be mapped again.

It seems that we are currently checking for {rhs} starts with the same letter than {lhs}, rather than {rhs} starts with {lhs}, which is causing trouble when we have two letters in lhs.
https://github.com/VsVim/VsVim/blob/master/Src/VimCore/KeyMap.fs#L77-L85

I am available for drafting a PR and some tests, if that would be welcome.

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

No branches or pull requests

1 participant