maxbrunsfeld / vim-yankstack

A lightweight implementation of emacs's kill-ring for vim
437 stars 29 forks source link

On windows, after pasting with `p`, typing `alt-p` does a new paste #13

Closed maxbrunsfeld closed 12 years ago

maxbrunsfeld commented 12 years ago

When alt-p is typed, yankstack is supposed to check whether or not the user just pasted. If so, it replaces the last text pasted with the text of an older yank. If not, it does a new paste. On windows gvim, it appears to be doing a new paste even after the user has just pasted with p. It does work correctly after the user pastes with alt-p. They can then cycle through their history of yanks.

Reported by @mMontu in issue #10

maxbrunsfeld commented 12 years ago

@mMontu, what output do you see for :nmap p?

mMontu commented 12 years ago

It outputs n p * <SNR>2_paste_with_key("p", "n").

This is the output for :nmap

n C * <SNR>2_yank_with_key("C") n D * <SNR>2_yank_with_key("D") n P * <SNR>2_paste_with_key("P", "n") n S * <SNR>2_yank_with_key("S") n X * <SNR>2_yank_with_key("X") n Y * <SNR>2_yank_with_key("Y") n c * <SNR>2_yank_with_key("c") n d * <SNR>2_yank_with_key("d") n gx <Plug>NetrwBrowseX n gP * <SNR>2_paste_with_key("gP", "n") n gp * <SNR>2_paste_with_key("gp", "n") n p * <SNR>2_paste_with_key("p", "n") n s * <SNR>2_yank_with_key("s") n x * <SNR>2_yank_with_key("x") n y * <SNR>2_yank_with_key("y") n <Plug>NetrwBrowseX * :call netrw#NetrwBrowseX(expand("<cWORD>"),0)<CR> n <Plug>yankstack_after_paste_v * :call <SNR>2_after_paste('v')<CR> n <Plug>yankstack_after_paste_n * :call <SNR>2_after_paste('n')<CR> n <Plug>yankstack_substitute_newer_paste * :<C-U>call <SNR>2_substitute_paste(-v:count1, 'n')<CR> n <Plug>yankstack_substitute_older_paste * :<C-U>call <SNR>2_substitute_paste(v:count1, 'n')<CR> n <S-Insert> "*P n Ð <Plug>yankstack_substitute_newer_paste n ð <Plug>yankstack_substitute_older_paste

The last two are alt-p and alt-P. Please let me know if I can help with any tests.

maxbrunsfeld commented 12 years ago

Hmmm, nothing looks obviously wrong with this. I notice there's two mapping names that are a few revisions old. Maybe try pulling the latest master.

gramic commented 12 years ago

It is the same for my setup under Ubuntu 12.04 inside gvim and terminal vim. Even with the default mappings, just out of the box works the same.

mMontu commented 12 years ago

I've tried with the latest master (-9fe0388), but the problem still exists.

The output of :nmap changed to:

  n  C           * <SNR>2_yank_with_key("C")
  n  D           * <SNR>2_yank_with_key("D")
  n  P           * <SNR>2_paste_with_key("P", "n")
  n  S           * <SNR>2_yank_with_key("S")
  n  X           * <SNR>2_yank_with_key("X")
  n  Y           * <SNR>2_yank_with_key("Y")
  n  c           * <SNR>2_yank_with_key("c")
  n  d           * <SNR>2_yank_with_key("d")
  n  gx            <Plug>NetrwBrowseX
  n  gP          * <SNR>2_paste_with_key("gP", "n")
  n  gp          * <SNR>2_paste_with_key("gp", "n")
  n  p           * <SNR>2_paste_with_key("p", "n")
  n  s           * <SNR>2_yank_with_key("s")
  n  x           * <SNR>2_yank_with_key("x")
  n  y           * <SNR>2_yank_with_key("y")
  n  <Plug>NetrwBrowseX * :call netrw#NetrwBrowseX(expand("<cWORD>"),0)<CR>
  n  <Plug>yankstack_after_paste * :call <SNR>2_after_paste()<CR>
  n  <Plug>yankstack_substitute_newer_paste * :<C-U>call <SNR>2_substitute_paste(-v:count1, 'n')<CR>
  n  <Plug>yankstack_substitute_older_paste * :<C-U>call <SNR>2_substitute_paste(v:count1, 'n')<CR>
  n  <S-Insert>    "*P
  n  Ð             <Plug>yankstack_substitute_newer_paste
  n  ð             <Plug>yankstack_substitute_older_paste

I'm downloading the code through https://github.com/maxbrunsfeld/vim-yankstack/downloads - it seems to point to the latest code. Is this correct?

maxbrunsfeld commented 12 years ago

Ok, I'm able to reproduce this bug on one of the versions of terminal vim that I have on my Mac, so I should be able to fix it now. Thanks for the reports.

mMontu commented 12 years ago

Nice!!

maxbrunsfeld commented 12 years ago

I think I got it. Check it out when you can!

mMontu commented 12 years ago

It indeed solved the problem, it is working very well.

Just curious: did you find out why it worked only on some versions of Vim? There are differences in the way mappings are handled on some versions?

Thank you very much!

maxbrunsfeld commented 12 years ago

Yeah, I think the issue was how I was using 'expression' mappings (:h <expr>) to remap the p and P keys. Different versions of vim appear to restrict different actions inside of those types of key mappings. Specifically, in the version of MacVim I was using calling feedkeys is allowed inside of an expression mapping, while in other versions of vim, it appeared to silently fail. So now I don't use expression mappings for pasting.