evil icon indicating copy to clipboard operation
evil copied to clipboard

incorrect behaviour of visual block paste

Open p00f opened this issue 9 months ago • 11 comments

Issue type

  • Bug report

Environment

Emacs version: GNU Emacs 29.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.41, cairo version 1.18.0) Operating System: Arch Linux Evil version: Evil version 1.15.0 Evil installation type: MELPA Graphical/Terminal: Graphical Tested in a make emacs session (see CONTRIBUTING.md): Yes

Reproduction steps

  • Start Emacs
  • Open this file:
aaaaaaaaaaaaa
bbbbbbbb
cccc
  • Do the following (I recorded a macro and opened it in the macro editor C-x C-k C-e)
;; Keyboard Macro Editor.  Press C-c C-c to finish; press C-x k RET to cancel.
;; Original keys: G k C-v g g $ y A 7*SPC <escape> p

Command: last-kbd-macro
Key: none

Macro:

G			;; evil-goto-line
k			;; evil-previous-line
C-v			;; evil-visual-block
g g			;; evil-goto-first-line
$			;; evil-end-of-line
y			;; evil-yank
A			;; evil-append-line
7*SPC			;; evil-forward-char
<escape>		;; evil-force-normal-state
p			;; evil-paste-after

Expected behavior

Tested in neovim:

aaaaaaaaaaaaa       aaaaaaaaaaaaa
bbbbbbbb            bbbbbbbb
cccc                cccc

Actual behavior

aaaaaaaaaaaaa       aaaaaaaaaaaaa
bbbbbbbb     
cccc         
bbbbbbbb
cccc

Further notes

p00f avatar Apr 28 '24 18:04 p00f

I am unable to reproduce using make emacs with GNU Emacs 29.3 in terminal.

axelf4 avatar Apr 29 '24 19:04 axelf4

Yeah I also can't repro. And the test in the above commit passes on all emacs versions we test for.

Also, for posterity, the keypresses seem wrong (i.e. they don't result in that output in vim either). Should be, with cursor on first a:

C-v
G
$
y
A
7*SPC
<escape>
p

but as I said, this also works in evil for me.

tomdl89 avatar Apr 29 '24 21:04 tomdl89

Yeah I also can't repro. And the test in the above commit passes on all emacs versions we test for.

Also, for posterity, the keypresses seem wrong (i.e. they don't result in that output in vim either). Should be, with cursor on first a:

C-v
G
$
y
A
7*SPC
<escape>
p

but as I said, this also works in evil for me.

I can reproduce your steps in make emacs too Screenshot from 2024-04-30 at 14_41_49 465644725

p00f avatar Apr 30 '24 09:04 p00f

I get that same result if I press C-r " in insert mode rather than p in normal mode, but that is consistent with vim anyway.

tomdl89 avatar Apr 30 '24 10:04 tomdl89

Interestingly, if I undo that, then paste with p, I do get the result you get. Which is inconsistent with vim... I feel like I'm getting close to a repro here.

tomdl89 avatar Apr 30 '24 10:04 tomdl89

Also, for posterity, the keypresses seem wrong (i.e. they don't result in that output in vim either).

Vim doesn't need the k after the G because it doesn't actually go to the final newline

p00f avatar Apr 30 '24 11:04 p00f

@p00f I can't really see why it would, but do you want to pull master and see if my latest change makes any difference? Otherwise, any clue as to why your setup would be any different from mine would be helpful. I'm running the same version of Emacs with the same version of evil on the same OS, so it does sound more likely a repro steps difference.

tomdl89 avatar Apr 30 '24 13:04 tomdl89

Nope

p00f avatar Apr 30 '24 13:04 p00f

OK, I can't promise I'll look any further into this until you can supply repro steps that work on my machine, but I'll leave it open in case you do.

tomdl89 avatar Apr 30 '24 13:04 tomdl89

Is make emacs not clean enough, should I try installing evil on emacs -Q?

p00f avatar Apr 30 '24 13:04 p00f

make emacs is emacs -Q (plus loading the necessary evil files), so I can't imagine that would make any difference.

tomdl89 avatar Apr 30 '24 13:04 tomdl89

@p00f do you have any clipboard manager that may be interfering? One way to eliminate that would be to yank into a register and paste from it. E.g.

"               ; <- do this before C-v because doing it after $ loses the eol-anchoring
x
C-v
G
$
y
A
7*SPC
<escape>
"
x
p

As commented, I've realised that choosing a register breaks the end-of-line selection. That's a bug that needs fixing. But ignoring that, let me know if the above gets you the correct result. If it does, it implies that something (probably outside of emacs) is clobbering the copied text.

tomdl89 avatar May 07 '24 15:05 tomdl89

It does get the correct result, but I use the same clipboard manager with neovim (clipman) and it behaves correctly

p00f avatar May 07 '24 17:05 p00f

It works correctly after reinstalling emacs (or maybe because some package got upgraded), sorry for wasting your time

p00f avatar May 07 '24 17:05 p00f