mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 01:34:25 +00:00 
			
		
		
		
	paste: fix normal-mode paste by different approach #10976
Forcing insert-mode after the first paste-chunk seems to work, as an alternative toa9e2bae0eb(insert-before-cursor). NB: Dot-repeat needs to match the original action. Sincea9e2bae0ebchanged paste to insert-before-cursor, dot-repeat must also. But that makes dot-repeat unpleasant/unusual.
This commit is contained in:
		@@ -239,7 +239,7 @@ GUIs can paste by calling |nvim_paste()|.
 | 
			
		||||
 | 
			
		||||
PASTE BEHAVIOR ~
 | 
			
		||||
 | 
			
		||||
Paste inserts text before the cursor.  Lines break at <NL>, <CR> and <CR><NL>.
 | 
			
		||||
Paste inserts text after the cursor.  Lines break at <NL>, <CR>, and <CR><NL>.
 | 
			
		||||
When pasting a huge amount of text, screen-updates are throttled and the
 | 
			
		||||
message area shows a "..." pulse.
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -191,9 +191,15 @@ paste = (function()
 | 
			
		||||
      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 ~= 'c' then
 | 
			
		||||
    elseif mode ~= 'c' then  -- Else: discard remaining cmdline-mode chunks.
 | 
			
		||||
      if phase < 2 and mode ~= 'i' and mode ~= 'R' then
 | 
			
		||||
        vim.api.nvim_put(lines, 'c', true, true)
 | 
			
		||||
        -- XXX: Normal-mode: workaround bad cursor-placement after first chunk.
 | 
			
		||||
        vim.api.nvim_command('normal! a')
 | 
			
		||||
      else
 | 
			
		||||
        vim.api.nvim_put(lines, 'c', false, true)
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    if phase ~= -1 and (now - tdots >= 100) then
 | 
			
		||||
      local dots = ('.'):rep(tick % 4)
 | 
			
		||||
      tdots = now
 | 
			
		||||
 
 | 
			
		||||
@@ -319,7 +319,7 @@ describe('TUI', function()
 | 
			
		||||
      {1:x}                                                 |
 | 
			
		||||
      {4:~                                                 }|
 | 
			
		||||
      {5:[No Name] [+]                   3,1            All}|
 | 
			
		||||
      :set ruler                                        |
 | 
			
		||||
                                                        |
 | 
			
		||||
      {3:-- TERMINAL --}                                    |
 | 
			
		||||
    ]]
 | 
			
		||||
    local expected_attr = {
 | 
			
		||||
@@ -485,9 +485,9 @@ describe('TUI', function()
 | 
			
		||||
    feed_data('\n')  -- <CR>
 | 
			
		||||
    screen:expect{grid=[[
 | 
			
		||||
      foo                                               |
 | 
			
		||||
      typed input..line A                               |
 | 
			
		||||
      typed input...line A                              |
 | 
			
		||||
      line B                                            |
 | 
			
		||||
      {1:.}                                                 |
 | 
			
		||||
      {1: }                                                 |
 | 
			
		||||
      {5:[No Name] [+]                                     }|
 | 
			
		||||
                                                        |
 | 
			
		||||
      {3:-- TERMINAL --}                                    |
 | 
			
		||||
@@ -512,7 +512,7 @@ describe('TUI', function()
 | 
			
		||||
                                                        |
 | 
			
		||||
      {4:~                                                 }|
 | 
			
		||||
      {5:                                                  }|
 | 
			
		||||
      {8:paste: Error executing lua: vim.lua:195: Vim:E21: }|
 | 
			
		||||
      {8:paste: Error executing lua: vim.lua:196: Vim:E21: }|
 | 
			
		||||
      {8:Cannot make changes, 'modifiable' is off}          |
 | 
			
		||||
      {10:Press ENTER or type command to continue}{1: }          |
 | 
			
		||||
      {3:-- TERMINAL --}                                    |
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user