-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Langmap things #6494
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
base: master
Are you sure you want to change the base?
Langmap things #6494
Conversation
591293a
to
41083a9
Compare
41083a9
to
ac0ddd2
Compare
ac0ddd2
to
fb59a81
Compare
end) | ||
-- pending('-- More -- prompt', function() | ||
-- -- The 'b' 'j' 'd' 'f' commands at the -- More -- prompt | ||
-- end) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this still needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test should be implemented, but I couldn't immediately see how to write it and just left it as a comment.
local curwin = helpers.curwin | ||
|
||
describe("'langmap'", function() | ||
clear() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this needed? it's already in before_each()
.
In 5414960 this wording doesn't make sense to me:
A lot of things in that paragraph seem contradictory. Can it be reworded? |
src/nvim/getchar.c
Outdated
@@ -1465,9 +1465,10 @@ int vgetc(void) | |||
* converted character. | |||
* Note: This will loop until enough bytes are received! | |||
*/ | |||
if (has_mbyte && (n = MB_BYTE2LEN_CHECK(c)) > 1) { | |||
buf[0] = (char_u)c; | |||
i = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is an odd place to put this, because it's done again on line 1472. Perhaps this should go in a else {}
block?
-- This is a reasonably easy fix, but it doesn't make sense to fix this and | ||
-- not translating text recorded in the macro when mappings are not | ||
-- applied. | ||
feed_command('nnoremap w l') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use command
in most cases, unless the asynchrony of feed_command
is needed.
Just as a caveat -- at the time I made this PR Yeah I apologise about that commit message, what I was trying to say was:
A less kind-to-me way of putting it is: I'm lazy and like the changes in functionality this introduces so I'm not going to bother adding code to get rid of it. On the other hand, I don't think I can justify changing all the other cases just because I don't like them in what claims to be a bug-fix / code-neaten PR. |
To note (thought this might be unclear just from the commits).
|
I just noticed a bug while recording macros under this PR and wanted to mention it so the bug doesn't get merged. The bug can be seen using a special key like Starting with
you see that the macro doesn't replay the same actions that happened while it was being recorded. I'll get round to fixing it, but in a while ... I still believe the commit changing the definition of the |
4bcafd5
to
7ea83a2
Compare
@hardenedapple Which commits here are ready to merge? |
@justinmk I'll have a look at this over the next week (probably next weekend). There is one commit that fixes a simple bug, while the other commits are around From what I remember, this PR worked fine, but changing I'll need to find those parts of the tests I introduced to check the macro Once I've done that I'll create a separate PR containing the tests for the |
7ea83a2
to
f76efd8
Compare
f76efd8
to
bf6ddc3
Compare
After the merge of #7919 this has been rebased onto master. |
bf6ddc3
to
5289a02
Compare
5289a02
to
502f171
Compare
502f171
to
b1cde5a
Compare
We put LANGMAP_ADJUST() in vgetc() instead of vgetorpeekc(), because vgetc() is the first place that vim switches from handling bytes to characters. The only place vgetorpeek() is called outside of vgetc() is vpeekc() Each of the calling places of this is written below, along with the reason that not applying LANGMAP in that case is fine. insertchar() (in INSERT mode) command_line_execute() (in CMDLINE mode) command_line_changed() (in CMDLINE mode) getexline() (used when executing from register) openscript() (return value is not used) vpeekc_any() which is used in ins_compl_check_keys() (in INSERT mode) f_getchar() (checked against empty (i.e. LANGMAP doesn't matter) command_line_changed() (check for empty) char_avail() (checked against empty) normal_get_additional_char() (Check for empty, Check for empty, Check for multibyte to determine whether need to read more, any more is read with plain_vgetc()) do_mouse() (Check for empty) Before this commit, there are 7 exceptions to the rule that 'langmap' is applied whenever neovim takes a key to be interpreted as a command. These exceptions are mentioned in the test spec. This commit changes two of these so they are no longer exceptions, these are: confirming whether to apply a substitution after :s///c, and asking y/n after a backwards range. I'm leaving the changes as I believe they are improvements. On the other hand, I'm not changing the behaviour of the other exceptions despite being of the opinion that they should change, as the point of this commit is to record the 'langmap' translation in macros, not to change when the 'langmap' translation is applied.
b1cde5a
to
51fbd52
Compare
@hardenedapple Now would be a good time to merge this. But users won't know about it unless we describe it. Can you suggest a documentation update, or at least a brief description of the behavior changes? |
Tested, it fixes macro behaviors of langmap. Sweet! |
@justinmk I've just merged with master and re-run the tests. One thing that surprised me:If you remember from my comment above #6494 (comment) , there were some exceptions to the general rule of "commands have LANGMAP applied" that I recorded in the testsuite. Frankly I don't understand the previous behaviour (haven't spent enough time investigating since I'm not worried about it) but the current behaviour makes sense. Overall, the PR doesn't seem to have bitrotted too much. Documentation changes?In regards to documentation changes: The idea is that this series makes things work as one would expect from the documentation as it is. The differences are:
Apologies for going dark -- I got more busy ;-) |
I still can't understand, does this PR fixes the vim/vim#3018 bug, and specifically vim/vim#7458 bug of not supporting multibyte chars in "from" ? |
I had written some tests initially intending to fix the problems they show.I've made some improvements in theI've changed my mind, and don't plan on fixing them, as, frankly it's not a pain point for me, and it seems like a lot of effort.
'langmap'
option by recording the translated keys.I have also covered two special cases that were previously not translated. I think this is an improvement, but others may disagree.
I have left other special cases alone despite thinking they may be better changed -- that's a topic I'd like to get input on.
n.b. the recording of
'langmap'
translations in macros was discussed here.