machakann / vim-highlightedyank

Make the yanked region apparent!
844 stars 22 forks source link

fix " register saving #16

Closed lilydjwg closed 7 years ago

lilydjwg commented 7 years ago

It conflicted with the ConflictMotion plugin. It reverted the yanked text so ConflictMotion got the wrong content. ConflictMotion tries to save, yank & return @" and restore to get the text to perserve.

I still don't know why this only breaks ConflictMotion, but after the fix everything seems fine.

machakann commented 7 years ago

Excuse me, I don't really understand the problem. I would be happy if you let me know the way to reproduce.

lilydjwg commented 7 years ago

Oh sorry I forgot to explain the problem. Install the plugins.

First of all, setup highlightedyank:

map y <Plug>(highlightedyank)

Then try to edit a conflict text like this:

<<<<<<< HEAD
foo
=======
bar
>>>>>>> remote

Put the cursor at foo and then run :ConflictTake, the text should be changed to

foo

But with highlightedyank's mapping setup, it changed to whatever you've previously yanked to ".

machakann commented 7 years ago

Thank you for your clear explanation! Now I've got!

Unfortunately, your fix changes the context and may have sub-effect. In addition, I will get rid of the s:get_buf_text() function near future 😁 , then the problem could appear again. I think the below patch also can solve the problem. Could you test it and update if it works?

diff --git a/autoload/highlightedyank.vim b/autoload/highlightedyank.vim
index 1d4aab1..c747d58 100644
--- a/autoload/highlightedyank.vim
+++ b/autoload/highlightedyank.vim
@@ -61,7 +61,7 @@ function! s:yank_normal(count, register) abort "{{{
     if region != s:null_region
       call s:highlight_yanked_region(region)
       let keyseq = printf('%s%s%s%s', a:register, a:count, s:normal['y'], input)
-      call feedkeys(keyseq, 'it')
+      call feedkeys(keyseq, 'itx')
     endif
   finally
     call winrestview(view)
@@ -86,7 +86,7 @@ function! s:yank_visual(register) abort "{{{
   try
     call s:highlight_yanked_region(region)
     let keyseq = printf('%s%s%s', s:normal['gv'], a:register, s:normal['y'])
-    call feedkeys(keyseq, 'it')
+    call feedkeys(keyseq, 'itx')
   finally
     call winrestview(view)
     call s:restore_options(options)
lilydjwg commented 7 years ago

Yes it works! Thank you!

machakann commented 7 years ago

Thank you very much!!