mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-03 17:24:29 +00:00 
			
		
		
		
	fix(paste): ignore mappings in Cmdline mode (#18114)
This commit is contained in:
		@@ -174,11 +174,11 @@ do
 | 
			
		||||
    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().
 | 
			
		||||
        -- Escape "<" and control characters
 | 
			
		||||
        local line1 = lines[1]:gsub('<', '<lt>'):gsub('(%c)', '\022%1')
 | 
			
		||||
        vim.api.nvim_input(line1)
 | 
			
		||||
        vim.api.nvim_set_option('paste', false)
 | 
			
		||||
        -- Escape control characters
 | 
			
		||||
        local line1 = lines[1]:gsub('(%c)', '\022%1')
 | 
			
		||||
        -- nvim_input() is affected by mappings,
 | 
			
		||||
        -- so use nvim_feedkeys() with "n" flag to ignore mappings.
 | 
			
		||||
        vim.api.nvim_feedkeys(line1, 'n', true)
 | 
			
		||||
      end
 | 
			
		||||
      return true
 | 
			
		||||
    end
 | 
			
		||||
 
 | 
			
		||||
@@ -1085,6 +1085,12 @@ describe('API', function()
 | 
			
		||||
      eq('aabbccdd', funcs.getcmdline())
 | 
			
		||||
      expect('')
 | 
			
		||||
    end)
 | 
			
		||||
    it('mappings are disabled in Cmdline mode', function()
 | 
			
		||||
      command('cnoremap a b')
 | 
			
		||||
      feed(':')
 | 
			
		||||
      nvim('paste', 'a', true, -1)
 | 
			
		||||
      eq('a', funcs.getcmdline())
 | 
			
		||||
    end)
 | 
			
		||||
    it('pasting with empty last chunk in Cmdline mode', function()
 | 
			
		||||
      local screen = Screen.new(20, 4)
 | 
			
		||||
      screen:attach()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user