-
Notifications
You must be signed in to change notification settings - Fork 742
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
First stab at <Plug> mappings #105
Conversation
Using a non-existent key stroke is great, but ambiguous plug mappings aren't supported out of the box. Imagine you have two mappings, both of which take a motion: <Plug>More <Plug>MoreMagic You've mapped gmm to <Plug>More and gmc to <Plug>MoreMagic. When you type gmc, the recursive mapping is available, and the `else if (mappingInfo != null)` branch can feed the mapped keys back into the system. Because these are fed as recursive, when the keys come back through, they can get the mapping to MoreMagic (which is no longer a prefix) and execute. For gmm, when it feeds the keys for <Plug>More, it is still a prefix; when a motion is inputted, it is no longer a prefix, and so it would hit the `else` block, feeding the keys WITHOUT recursion. So, we have to catch the case where we're no longer a prefix, but can find a <Plug> mapping within the input. This seems to work pretty well, but causes "recursive records found" warnings in the console, and complaints about local history being broken. I'm not entirely sure whether this is just an idiosyncrasy of the unit test environment, or whether this would cause significant problems in the live environment. Also included is some prep work for <Plug>-based repeat handling. Extra input sequences past the <Plug> mapping are stored in a PlugInputModel which is read from in preference to the ModalInputDialog.
7d4f2ef
to
c28a65a
Compare
It seems like the "recursive records found" is also printed when I run the test on |
Also, it seems the ambiguous mappings is not just an issue for @vlasovskikh thoughts? |
I'll look at this PR in more detail on the weekend. The general idea should be to emulate ambiguous mappings as close to Vim as possible. At the moment I'm very concerned with VIM-1086. |
I just added some more tests. The techniques here actually do handle ambiguous, direct (IE: not There is still a bug if you do those sort of mappings with the |
Okay just pushed some changes that fix the test case I had. |
I'm not sure about this weekend, but this is the next PR I'll look at. |
@dhleong Fixing prefix remappings is then a different problem and at least won't suprpise extension authors. |
That's certainly one approach. I'm hesitant to break from Vim's behavior On Thu, Feb 25, 2016 at 11:11 AM Bert Jacobs notifications@github.com
|
I'm going to restore the original Vim behavior in IdeaVim regarding ambiguous mappings with |
As for |
The comments extension requires ambiguous mappings. Doesn't use On Sun, Feb 28, 2016 at 6:38 PM Andrey Vlasovskikh notifications@github.com
|
I still haven't managed to spend some time working on this PR yet. Hope things will get better the next weekend. |
Using a non-existent key stroke is great, but ambiguous
plug mappings aren't supported out of the box. Imagine you
have two mappings, both of which take a motion:
More
MoreMagic
You've mapped gmm to More and gmc to MoreMagic.
When you type gmc, the recursive mapping is available, and the
else if (mappingInfo != null)
branch can feed the mapped keysback into the system. Because these are fed as recursive, when
the keys come back through, they can get the mapping to MoreMagic
(which is no longer a prefix) and execute.
For gmm, when it feeds the keys for More, it is still
a prefix; when a motion is inputted, it is no longer a prefix,
and so it would hit the
else
block, feeding the keys WITHOUTrecursion. So, we have to catch the case where we're no longer
a prefix, but can find a mapping within the input. This
seems to work pretty well, but causes "recursive records found"
warnings in the console, and complaints about local history being
broken. I'm not entirely sure whether this is just an idiosyncrasy
of the unit test environment, or whether this would cause
significant problems in the live environment. I'm hoping you have
more experience here about whether that warning can be ignored,
and am open to suggestions otherwise.
Also included is some prep work for -based repeat handling.
Extra input sequences past the mapping are stored in a
PlugInputModel which is read from in preference to the
ModalInputDialog.