aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-08-20 22:41:21 +0200
committerJustin M. Keyes <justinkz@gmail.com>2019-08-27 21:19:10 +0200
commit613296936ba30ae73f3391c2e3c36096f3703c06 (patch)
tree99944e295d8e5d62f4af4de68590b4facb82373e
parent1fdae25b2b932439fdef9e70b42e82e3153b937a (diff)
downloadrneovim-613296936ba30ae73f3391c2e3c36096f3703c06.tar.gz
rneovim-613296936ba30ae73f3391c2e3c36096f3703c06.tar.bz2
rneovim-613296936ba30ae73f3391c2e3c36096f3703c06.zip
API: nvim_put: always PUT_CURSEND
Fixes strange behavior where sometimes the buffer contents of a series of paste chunks (vim._paste) would be out-of-order. Now the tui_spec.lua screen-tests are much more reliable. But they still sometimes fail because of off-by-one cursor (caused by "typeahead race" resulting in wrong mode; fixed later in this patch-series).
-rw-r--r--src/nvim/api/vim.c8
-rw-r--r--test/functional/api/vim_spec.lua1
-rw-r--r--test/functional/terminal/tui_spec.lua17
3 files changed, 16 insertions, 10 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 900c3bab58..d3e368d01b 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -1249,13 +1249,7 @@ void nvim_put(ArrayOf(String) lines, String type, Boolean direction,
finish_yankreg_from_object(reg, false);
bool VIsual_was_active = VIsual_active;
- int flags = 0;
- if (State & INSERT) {
- flags |= PUT_CURSEND;
- } else if (VIsual_active) {
- // TODO: fix VIsual when cursor is before, or emulate the delete as well
- flags |= lt(VIsual, curwin->w_cursor) ? PUT_CURSEND : 0;
- }
+ int flags = PUT_CURSEND;
msg_silent++; // Avoid "N more lines" message.
do_put(0, reg, direction ? BACKWARD : FORWARD, 1, flags);
msg_silent--;
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 09c297940c..20046147b8 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -382,6 +382,7 @@ describe('API', function()
line 1
line 2
line 3]])
+ command('1')
-- blockwise
nvim('put', {'AA','BB'}, 'b', false)
expect([[
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index e63d47bbc2..3719af005c 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -190,9 +190,16 @@ describe('TUI', function()
end)
it('paste: exactly 64 bytes #10311', function()
+ local expected = string.rep('z', 64)
-- "bracketed paste"
- feed_data('i\027[200~'..string.rep('z', 64)..'\027[201~')
+ feed_data('i\027[200~'..expected..'\027[201~')
feed_data(' end')
+ expected = expected..' end'
+ retry(nil, nil, function()
+ local _, buflines = child_session:request(
+ 'nvim_buf_get_lines', 0, 0, -1, false)
+ eq({expected}, buflines)
+ end)
screen:expect([[
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz|
zzzzzzzzzzzzzz end{1: } |
@@ -210,9 +217,13 @@ describe('TUI', function()
for i = 1, 3000 do
t[i] = 'item ' .. tostring(i)
end
- local expected = table.concat(t, '\n')
-- "bracketed paste"
- feed_data('i\027[200~'..expected..'\027[201~')
+ feed_data('i\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)
+ eq(t, buflines)
+ end)
feed_data(' end')
screen:expect([[
item 2997 |