aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-08-19 00:18:41 +0200
committerJustin M. Keyes <justinkz@gmail.com>2019-08-27 21:19:10 +0200
commit68ea9a7c8a7a74ec6ec9782528527cf70b92a376 (patch)
tree0b05e5f1ad611912163dcccf100bf965c1499a4f
parent6d277f43a287d62c10fb1ed8d93247ddf4a437d9 (diff)
downloadrneovim-68ea9a7c8a7a74ec6ec9782528527cf70b92a376.tar.gz
rneovim-68ea9a7c8a7a74ec6ec9782528527cf70b92a376.tar.bz2
rneovim-68ea9a7c8a7a74ec6ec9782528527cf70b92a376.zip
TUI/paste: always flush on paste mode-change
Flush input before entering, not only when leaving, paste mode. Else there could be pending input which will erroneously be sent to the paste handler.
-rw-r--r--src/nvim/lua/vim.lua10
-rw-r--r--src/nvim/tui/input.c6
-rw-r--r--test/functional/terminal/tui_spec.lua19
3 files changed, 16 insertions, 19 deletions
diff --git a/src/nvim/lua/vim.lua b/src/nvim/lua/vim.lua
index 922878d6ce..47feba0f85 100644
--- a/src/nvim/lua/vim.lua
+++ b/src/nvim/lua/vim.lua
@@ -96,17 +96,19 @@ end
-- Default paste function.
local function _paste(data)
-- local eof = (data == {''})
- local curline = vim.api.nvim_call_function('line', {'.'})
+ local curline = vim.api.nvim_call_function('line', {'.'}) - 1
vim.api.nvim_buf_set_lines(
0,
curline,
curline,
false,
data)
- vim.api.nvim_call_function('cursor', {curline + #data, 1})
+ vim.api.nvim_call_function(
+ 'cursor',
+ {curline + #data, 9999999})
+ -- TODO: do not redraw (slow!) until paste is finished.
-- if eof then
- -- vim.api.nvim_command('redraw')
- -- end
+ vim.api.nvim_command('redraw')
return 0
end
diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c
index dc79a22862..b16f93ae66 100644
--- a/src/nvim/tui/input.c
+++ b/src/nvim/tui/input.c
@@ -16,8 +16,6 @@
#include "nvim/os/input.h"
#include "nvim/event/rstream.h"
-#define PASTE_KEY "<Paste>"
-#define PASTEPOST_KEY "<PastePost>"
#define KEY_BUFFER_SIZE 0xfff
#ifdef INCLUDE_GENERATED_DECLARATIONS
@@ -401,9 +399,7 @@ static bool handle_bracketed_paste(TermInput *input)
return true;
}
- if (!enable) {
- tinput_flush(input, true);
- }
+ tinput_flush(input, true);
input->paste_enabled = enable;
return true;
}
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index af55ec1555..b990652fc0 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -146,10 +146,8 @@ describe('TUI', function()
]], attrs)
end)
- it('automatically sends <Paste> for bracketed paste sequences', function()
+ it('bracketed Paste', function()
-- Pasting can be really slow in the TUI, specially in ASAN.
- -- This will be fixed later but for now we require a high timeout.
- screen.timeout = 60000
feed_data('i\027[200~')
screen:expect([[
{1: } |
@@ -157,27 +155,28 @@ describe('TUI', function()
{4:~ }|
{4:~ }|
{5:[No Name] }|
- {3:-- INSERT (paste) --} |
+ {3:-- INSERT --} |
{3:-- TERMINAL --} |
]])
feed_data('pasted from terminal')
screen:expect([[
pasted from terminal{1: } |
- {4:~ }|
+ |
{4:~ }|
{4:~ }|
{5:[No Name] [+] }|
- {3:-- INSERT (paste) --} |
+ {3:-- INSERT --} |
{3:-- TERMINAL --} |
]])
- feed_data('\027[201~')
+ feed_data('\027[201~') -- End paste.
+ feed_data('\027\000') -- ESC: go to Normal mode.
screen:expect([[
- pasted from terminal{1: } |
- {4:~ }|
+ pasted from termina{1:l} |
+ |
{4:~ }|
{4:~ }|
{5:[No Name] [+] }|
- {3:-- INSERT --} |
+ |
{3:-- TERMINAL --} |
]])
end)