mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor(paste): do not print dots in cmdline mode
This commit is contained in:
parent
bfb7754442
commit
21ba2d81a8
@ -157,20 +157,25 @@ do
|
||||
---@returns false if client should cancel the paste.
|
||||
function vim.paste(lines, phase)
|
||||
local now = vim.loop.now()
|
||||
local mode = vim.api.nvim_get_mode().mode
|
||||
local is_cmdline = vim.fn.getcmdtype() ~= ''
|
||||
if phase < 2 then -- Reset flags.
|
||||
local is_first_chunk = phase < 2
|
||||
if is_first_chunk then -- Reset flags.
|
||||
tdots, tick, got_line1 = now, 0, false
|
||||
elseif not is_cmdline then
|
||||
vim.api.nvim_command('undojoin')
|
||||
end
|
||||
if is_cmdline and not got_line1 then -- cmdline-mode: paste only 1 line.
|
||||
-- Note: mode doesn't always start with "c" in cmdline mode, so use getcmdtype() instead.
|
||||
if vim.fn.getcmdtype() ~= '' then -- cmdline-mode: paste only 1 line.
|
||||
if not got_line1 then
|
||||
got_line1 = (#lines > 1)
|
||||
vim.api.nvim_set_option('paste', true) -- For nvim_input().
|
||||
local line1 = lines[1]:gsub('<', '<lt>'):gsub('[\r\n\012\027]', ' ') -- Scrub.
|
||||
vim.api.nvim_input(line1)
|
||||
vim.api.nvim_set_option('paste', false)
|
||||
elseif not is_cmdline then
|
||||
end
|
||||
return true
|
||||
end
|
||||
local mode = vim.api.nvim_get_mode().mode
|
||||
if not is_first_chunk then
|
||||
vim.api.nvim_command('undojoin')
|
||||
end
|
||||
if mode:find('^i') or mode:find('^n?t') then -- Insert mode or Terminal buffer
|
||||
vim.api.nvim_put(lines, 'c', false, true)
|
||||
elseif phase < 2 and mode:find('^R') and not mode:find('^Rv') then -- Replace mode
|
||||
@ -211,7 +216,6 @@ do
|
||||
else -- Don't know what to do in other modes
|
||||
return false
|
||||
end
|
||||
end
|
||||
if phase ~= -1 and (now - tdots >= 100) then
|
||||
local dots = ('.'):rep(tick % 4)
|
||||
tdots = now
|
||||
|
Loading…
Reference in New Issue
Block a user