From d91f4cd7d0b9778ad8ed630d5b8dc6b197513f51 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 8 Sep 2019 14:58:47 -0700 Subject: paste: reset 'paste' option immediately #10974 - Workaround #10966: 'paste' option is not always reset. - In any case there's not much reason to wait until phase=3, because pasting in cmdline-mode skips lines after the first line (thus the `:set paste .. :set nopaste` dance happens only ~once). --- src/nvim/lua/vim.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/lua') diff --git a/src/nvim/lua/vim.lua b/src/nvim/lua/vim.lua index 99299c6073..e76dd9d062 100644 --- a/src/nvim/lua/vim.lua +++ b/src/nvim/lua/vim.lua @@ -188,8 +188,9 @@ paste = (function() if mode == 'c' and not got_line1 then -- cmdline-mode: paste only 1 line. got_line1 = (#lines > 1) vim.api.nvim_set_option('paste', true) -- For nvim_input(). - local line1, _ = string.gsub(lines[1], '[\r\n\012\027]', ' ') - vim.api.nvim_input(line1) -- Scrub "\r". + local line1, _ = string.gsub(lines[1], '[\r\n\012\027]', ' ') -- Scrub. + vim.api.nvim_input(line1) + vim.api.nvim_set_option('paste', false) elseif mode == 'i' or mode == 'R' then vim.api.nvim_put(lines, 'c', false, true) else @@ -206,7 +207,6 @@ paste = (function() if phase == -1 or phase == 3 then vim.api.nvim_command('redraw') vim.api.nvim_command('echo ""') - vim.api.nvim_set_option('paste', false) end return true -- Paste will not continue if not returning `true`. end -- cgit