mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
refactor(paste): do not print dots in cmdline mode
This commit is contained in:
@@ -157,20 +157,25 @@ do
|
|||||||
---@returns false if client should cancel the paste.
|
---@returns false if client should cancel the paste.
|
||||||
function vim.paste(lines, phase)
|
function vim.paste(lines, phase)
|
||||||
local now = vim.loop.now()
|
local now = vim.loop.now()
|
||||||
local mode = vim.api.nvim_get_mode().mode
|
local is_first_chunk = phase < 2
|
||||||
local is_cmdline = vim.fn.getcmdtype() ~= ''
|
if is_first_chunk then -- Reset flags.
|
||||||
if phase < 2 then -- Reset flags.
|
|
||||||
tdots, tick, got_line1 = now, 0, false
|
tdots, tick, got_line1 = now, 0, false
|
||||||
elseif not is_cmdline then
|
|
||||||
vim.api.nvim_command('undojoin')
|
|
||||||
end
|
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)
|
got_line1 = (#lines > 1)
|
||||||
vim.api.nvim_set_option('paste', true) -- For nvim_input().
|
vim.api.nvim_set_option('paste', true) -- For nvim_input().
|
||||||
local line1 = lines[1]:gsub('<', '<lt>'):gsub('[\r\n\012\027]', ' ') -- Scrub.
|
local line1 = lines[1]:gsub('<', '<lt>'):gsub('[\r\n\012\027]', ' ') -- Scrub.
|
||||||
vim.api.nvim_input(line1)
|
vim.api.nvim_input(line1)
|
||||||
vim.api.nvim_set_option('paste', false)
|
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
|
if mode:find('^i') or mode:find('^n?t') then -- Insert mode or Terminal buffer
|
||||||
vim.api.nvim_put(lines, 'c', false, true)
|
vim.api.nvim_put(lines, 'c', false, true)
|
||||||
elseif phase < 2 and mode:find('^R') and not mode:find('^Rv') then -- Replace mode
|
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
|
else -- Don't know what to do in other modes
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
|
||||||
if phase ~= -1 and (now - tdots >= 100) then
|
if phase ~= -1 and (now - tdots >= 100) then
|
||||||
local dots = ('.'):rep(tick % 4)
|
local dots = ('.'):rep(tick % 4)
|
||||||
tdots = now
|
tdots = now
|
||||||
|
|||||||
Reference in New Issue
Block a user