roxma / vim-tmux-clipboard

seamless integration for vim and tmux's clipboard
MIT License
290 stars 24 forks source link

Changes in #19 cause yank to drop trailing newlines #21

Closed daagaak closed 1 year ago

daagaak commented 1 year ago

It looks like the changes in #19 end up stripping the trailing newline that's yanked when doing line-wise yanks. This means that pasting those lines that inserts inline, instead of line-wise.

I think this is because the diffs in #19 are join()ing the buffer, meaning that the last entry will not have a \n added to it.

roxma commented 1 year ago

I have tested nvim v0.6.1. The Trailing newlines are not dropped.

  1. Modify the on_stdout function
    function! s:on_stdout(job_id, data, event)
     let @" = join(a:data, "\n")
    +    let g:my_data = a:data
    endfunction
  2. Run echo -n $'aaa\nbbbb\n\n' | tmux loadb -
  3. Start nvim
  4. Run :echo g:my_data. nvim outputs ['aaa', 'bbbb', '', '']
daagaak commented 1 year ago

Agreed, my test shows the same as yours. I wonder what's wrong then. If I do the following:

  1. Start nvim (0.8.2 here)
  2. Type out
    the quick brown
    fox jumped
    over the lazy dog
  3. Move the cursor to the d of jumped.
  4. yyp

The yanked line pastes inline, as if the trailing \n has been dropped (so I get fox jumpedfox jumped). If I disable vim-tmux-clipboard then the paste does a line-wise paste as I expected.

kristinn commented 1 year ago

I'm also experiencing this issue. If I remove this plugin my yanking works as usual.

I haven't been using vim extensively for a while but I don't remember this ever being an issue.

kristinn commented 1 year ago

Just wanted to add an update.

Yanking with new lines work perfectly by checking out commit f7dd0381533c2e15d83e7566e2690f540b8927e2 of this plugin. 😄

roxma commented 1 year ago

Please test the latest commit e1be6608410c260479dc4807ad8c103faf5460d8

kristinn commented 1 year ago

That one works for me. 😄

Thanks for this project and for a quick fix. Great job! 💯