mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
fix: assert failure when changing 'ut' while waiting for CursorHold (#20241)
This commit is contained in:
@@ -133,7 +133,7 @@ int os_inchar(uint8_t *buf, int maxlen, int ms, int tb_change_cnt, MultiQueue *e
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
uint64_t wait_start = os_hrtime();
|
uint64_t wait_start = os_hrtime();
|
||||||
assert((int)p_ut >= cursorhold_time);
|
cursorhold_time = MIN(cursorhold_time, (int)p_ut);
|
||||||
if ((result = inbuf_poll((int)p_ut - cursorhold_time, events)) == kInputNone) {
|
if ((result = inbuf_poll((int)p_ut - cursorhold_time, events)) == kInputNone) {
|
||||||
if (read_stream.closed && silent_mode) {
|
if (read_stream.closed && silent_mode) {
|
||||||
// Drained eventloop & initial input; exit silent/batch-mode (-es/-Es).
|
// Drained eventloop & initial input; exit silent/batch-mode (-es/-Es).
|
||||||
@@ -148,7 +148,6 @@ int os_inchar(uint8_t *buf, int maxlen, int ms, int tb_change_cnt, MultiQueue *e
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cursorhold_time += (int)((os_hrtime() - wait_start) / 1000000);
|
cursorhold_time += (int)((os_hrtime() - wait_start) / 1000000);
|
||||||
cursorhold_time = MIN(cursorhold_time, (int)p_ut);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,7 +2,6 @@ local helpers = require('test.functional.helpers')(after_each)
|
|||||||
|
|
||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
local eval = helpers.eval
|
|
||||||
local feed = helpers.feed
|
local feed = helpers.feed
|
||||||
local retry = helpers.retry
|
local retry = helpers.retry
|
||||||
local exec = helpers.source
|
local exec = helpers.source
|
||||||
@@ -12,13 +11,16 @@ local meths = helpers.meths
|
|||||||
before_each(clear)
|
before_each(clear)
|
||||||
|
|
||||||
describe('CursorHold', function()
|
describe('CursorHold', function()
|
||||||
it('is triggered correctly #12587', function()
|
before_each(function()
|
||||||
exec([[
|
exec([[
|
||||||
|
let g:cursorhold = 0
|
||||||
augroup test
|
augroup test
|
||||||
au CursorHold * let g:cursorhold += 1
|
au CursorHold * let g:cursorhold += 1
|
||||||
augroup END
|
augroup END
|
||||||
]])
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('is triggered correctly #12587', function()
|
||||||
local function test_cursorhold(fn, early)
|
local function test_cursorhold(fn, early)
|
||||||
local ut = 2
|
local ut = 2
|
||||||
-- if testing with small 'updatetime' fails, double its value and test again
|
-- if testing with small 'updatetime' fails, double its value and test again
|
||||||
@@ -47,6 +49,17 @@ describe('CursorHold', function()
|
|||||||
test_cursorhold(function() feed('<Ignore>') end, 0)
|
test_cursorhold(function() feed('<Ignore>') end, 0)
|
||||||
test_cursorhold(function() meths.feedkeys(ignore_key, 'n', true) end, 0)
|
test_cursorhold(function() meths.feedkeys(ignore_key, 'n', true) end, 0)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it("reducing 'updatetime' while waiting for CursorHold #20241", function()
|
||||||
|
meths.set_option('updatetime', 10000)
|
||||||
|
feed('0') -- reset did_cursorhold
|
||||||
|
meths.set_var('cursorhold', 0)
|
||||||
|
sleep(50)
|
||||||
|
eq(0, meths.get_var('cursorhold'))
|
||||||
|
meths.set_option('updatetime', 20)
|
||||||
|
sleep(10)
|
||||||
|
eq(1, meths.get_var('cursorhold'))
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('CursorHoldI', function()
|
describe('CursorHoldI', function()
|
||||||
@@ -64,7 +77,7 @@ describe('CursorHoldI', function()
|
|||||||
feed('ifoo')
|
feed('ifoo')
|
||||||
retry(5, nil, function()
|
retry(5, nil, function()
|
||||||
sleep(1)
|
sleep(1)
|
||||||
eq(1, eval('g:cursorhold'))
|
eq(1, meths.get_var('cursorhold'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user