vim-patch:8.1.2346: CTRL-R CTRL-R doesn't work with modifyOtherKeys

Problem:    CTRL-R CTRL-R doesn't work with modifyOtherKeys.
Solution:   Allow key codes when fetching argument for CTRL-R. (closes vim/vim#5266)
            Also fix CTRL-G in Insert mode.
38571a04b4

Omit test as it sends terminal codes. Use a Lua test instead.
This commit is contained in:
zeertzjq 2022-04-27 17:34:40 +08:00
parent 3090648584
commit 78a7e2d55c
3 changed files with 33 additions and 13 deletions

View File

@ -7817,11 +7817,10 @@ static void ins_reg(void)
}
/*
* Don't map the register name. This also prevents the mode message to be
* deleted when ESC is hit.
*/
++no_mapping;
// Don't map the register name. This also prevents the mode message to be
// deleted when ESC is hit.
no_mapping++;
allow_keys++;
regname = plain_vgetc();
LANGMAP_ADJUST(regname, TRUE);
if (regname == Ctrl_R || regname == Ctrl_O || regname == Ctrl_P) {
@ -7831,7 +7830,8 @@ static void ins_reg(void)
regname = plain_vgetc();
LANGMAP_ADJUST(regname, TRUE);
}
--no_mapping;
no_mapping--;
allow_keys--;
// Don't call u_sync() while typing the expression or giving an error
// message for it. Only call it explicitly.
@ -7899,13 +7899,13 @@ static void ins_ctrl_g(void)
// Right after CTRL-X the cursor will be after the ruler.
setcursor();
/*
* Don't map the second key. This also prevents the mode message to be
* deleted when ESC is hit.
*/
++no_mapping;
// Don't map the second key. This also prevents the mode message to be
// deleted when ESC is hit.
no_mapping++;
allow_keys++;
c = plain_vgetc();
--no_mapping;
no_mapping--;
allow_keys--;
switch (c) {
// CTRL-G k and CTRL-G <Up>: cursor up to Insstart.col
case K_UP:

View File

@ -1891,6 +1891,7 @@ static int command_line_handle_key(CommandLineState *s)
case Ctrl_R: { // insert register
putcmdline('"', true);
no_mapping++;
allow_keys++;
int i = s->c = plain_vgetc(); // CTRL-R <char>
if (i == Ctrl_O) {
i = Ctrl_R; // CTRL-R CTRL-O == CTRL-R CTRL-R
@ -1899,7 +1900,8 @@ static int command_line_handle_key(CommandLineState *s)
if (i == Ctrl_R) {
s->c = plain_vgetc(); // CTRL-R CTRL-R <char>
}
--no_mapping;
no_mapping--;
allow_keys--;
// Insert the result of an expression.
// Need to save the current command line, to be able to enter
// a new one...

View File

@ -8,6 +8,7 @@ local meths = helpers.meths
local exec_lua = helpers.exec_lua
local write_file = helpers.write_file
local funcs = helpers.funcs
local eval = helpers.eval
local Screen = require('test.functional.ui.screen')
before_each(clear)
@ -216,6 +217,23 @@ it('Ctrl-6 is Ctrl-^ vim-patch:8.1.2333', function()
eq('aaa', funcs.bufname())
end)
it('c_CTRL-R_CTRL-R, i_CTRL-R_CTRL-R, i_CTRL-G_CTRL-K work properly vim-patch:8.1.2346', function()
command('set timeoutlen=10')
command([[let @a = 'aaa']])
feed([[:let x = '<C-R><C-R>a'<CR>]])
eq([[let x = 'aaa']], eval('@:'))
feed('a<C-R><C-R>a<Esc>')
expect('aaa')
command('bwipe!')
feed('axx<CR>yy<C-G><C-K>a<Esc>')
expect([[
axx
yy]])
end)
it('typing a simplifiable key at hit-enter prompt triggers mapping vim-patch:8.2.0839', function()
local screen = Screen.new(60,8)
screen:set_default_attr_ids({