diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-08-22 00:19:46 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-08-27 21:19:10 +0200 |
commit | c95f5d166fad75ad8383f76675d06907687066a7 (patch) | |
tree | e68483db59bb3bef46c7c49d40e88f3286dc067e /test | |
parent | 5ae6849517d2a025c3359e771ac1e01a68ec24c8 (diff) | |
download | rneovim-c95f5d166fad75ad8383f76675d06907687066a7.tar.gz rneovim-c95f5d166fad75ad8383f76675d06907687066a7.tar.bz2 rneovim-c95f5d166fad75ad8383f76675d06907687066a7.zip |
paste: workaround typeahead race
Workaround this failure:
[ ERROR ] test/functional/terminal/tui_spec.lua @ 192: TUI paste: exactly 64 bytes
test/functional/helpers.lua:403:
retry() attempts: 478
test/functional/terminal/tui_spec.lua:201: Expected objects to be the same.
Passed in:
(table: 0x47cd77e8) {
*[1] = 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz endz' }
Expected:
(table: 0x47cd7830) {
*[1] = 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz end' }
This happens because `curwin->w_cursor.col` is sometimes decremented at
the end of `do_put`... because the editor is in Normal-mode instead of
the expected Insert-mode.
Caused by "typeahead race" (#10826): there may be queued input in the
main thread not yet processed, thus the editor mode (`State` global)
will be "wrong" during paste. Example: input "i" followed immediately by
a paste sequence:
i<start-paste>...<stop-paste>
^
"i" does not get processed in time, so the editor is in
Normal-mode instead of Insert-mode while handling the paste.
Attempted workarounds:
- vim.api.nvim_feedkeys('','x',false) in vim._paste()
- exec_normal() in tinput_wait_enqueue()
- LOOP_PROCESS_EVENTS(&main_loop,…,0) in tinput_wait_enqueue()
ref #10826
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/terminal/tui_spec.lua | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index 3719af005c..adf968712d 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -191,8 +191,14 @@ describe('TUI', function() it('paste: exactly 64 bytes #10311', function() local expected = string.rep('z', 64) + feed_data('i') + -- Wait for Insert-mode (avoid "typeahead race" #10826). + retry(nil, nil, function() + local _, m = child_session:request('nvim_get_mode') + eq('i', m.mode) + end) -- "bracketed paste" - feed_data('i\027[200~'..expected..'\027[201~') + feed_data('\027[200~'..expected..'\027[201~') feed_data(' end') expected = expected..' end' retry(nil, nil, function() @@ -217,8 +223,14 @@ describe('TUI', function() for i = 1, 3000 do t[i] = 'item ' .. tostring(i) end + feed_data('i') + -- Wait for Insert-mode (avoid "typeahead race" #10826). + retry(nil, nil, function() + local _, m = child_session:request('nvim_get_mode') + eq('i', m.mode) + end) -- "bracketed paste" - feed_data('i\027[200~'..table.concat(t, '\n')..'\027[201~') + feed_data('\027[200~'..table.concat(t, '\n')..'\027[201~') retry(nil, nil, function() local _, buflines = child_session:request( 'nvim_buf_get_lines', 0, 0, -1, false) |