emacs-evil / evil

The extensible vi layer for Emacs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

incorrect behaviour of visual block paste

p00f opened this issue · 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

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

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.

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

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.

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.

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 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.

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.

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

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

@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.

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

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