mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(event-loop): check if executed register has ended
This commit is contained in:
parent
2a574f7aaa
commit
64802da6c4
@ -2074,7 +2074,7 @@ void vungetc(int c)
|
|||||||
|
|
||||||
/// When peeking and not getting a character, reg_executing cannot be cleared
|
/// When peeking and not getting a character, reg_executing cannot be cleared
|
||||||
/// yet, so set a flag to clear it later.
|
/// yet, so set a flag to clear it later.
|
||||||
static void check_end_reg_executing(bool advance)
|
void check_end_reg_executing(bool advance)
|
||||||
{
|
{
|
||||||
if (reg_executing != 0 && (typebuf.tb_maplen == 0 || pending_end_reg_executing)) {
|
if (reg_executing != 0 && (typebuf.tb_maplen == 0 || pending_end_reg_executing)) {
|
||||||
if (advance) {
|
if (advance) {
|
||||||
|
@ -40,7 +40,7 @@ void state_enter(VimState *s)
|
|||||||
int key;
|
int key;
|
||||||
|
|
||||||
getkey:
|
getkey:
|
||||||
// Expand mappings first by calling vpeekc() directly.
|
// Apply mappings first by calling vpeekc() directly.
|
||||||
// - If vpeekc() returns non-NUL, there is a character already available for processing, so
|
// - If vpeekc() returns non-NUL, there is a character already available for processing, so
|
||||||
// don't block for events. vgetc() may still block, in case of an incomplete UTF-8 sequence.
|
// don't block for events. vgetc() may still block, in case of an incomplete UTF-8 sequence.
|
||||||
// - If vpeekc() returns NUL, vgetc() will block, and there are three cases:
|
// - If vpeekc() returns NUL, vgetc() will block, and there are three cases:
|
||||||
@ -76,6 +76,9 @@ getkey:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (key == K_EVENT) {
|
if (key == K_EVENT) {
|
||||||
|
// An event handler may use the value of reg_executing.
|
||||||
|
// Clear it if it should be cleared when getting the next character.
|
||||||
|
check_end_reg_executing(true);
|
||||||
may_sync_undo();
|
may_sync_undo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ local feed = helpers.feed
|
|||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
local expect = helpers.expect
|
local expect = helpers.expect
|
||||||
local command = helpers.command
|
local command = helpers.command
|
||||||
|
local funcs = helpers.funcs
|
||||||
local meths = helpers.meths
|
local meths = helpers.meths
|
||||||
local insert = helpers.insert
|
local insert = helpers.insert
|
||||||
local curbufmeths = helpers.curbufmeths
|
local curbufmeths = helpers.curbufmeths
|
||||||
@ -54,6 +55,19 @@ describe('immediately after a macro has finished executing,', function()
|
|||||||
command([[let @a = 'gg0']])
|
command([[let @a = 'gg0']])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
describe('reg_executing() from RPC returns an empty string', function()
|
||||||
|
it('if the macro does not end with a <Nop> mapping', function()
|
||||||
|
feed('@a')
|
||||||
|
eq('', funcs.reg_executing())
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('if the macro ends with a <Nop> mapping', function()
|
||||||
|
command('nnoremap 0 <Nop>')
|
||||||
|
feed('@a')
|
||||||
|
eq('', funcs.reg_executing())
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
describe('characters from a mapping are not treated as a part of the macro #18015', function()
|
describe('characters from a mapping are not treated as a part of the macro #18015', function()
|
||||||
before_each(function()
|
before_each(function()
|
||||||
command('nnoremap s qa')
|
command('nnoremap s qa')
|
||||||
|
Loading…
Reference in New Issue
Block a user