Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pasting text doesn't work properly in evil-mode #756

Closed
tbo opened this issue Jun 19, 2016 · 13 comments
Closed

Pasting text doesn't work properly in evil-mode #756

tbo opened this issue Jun 19, 2016 · 13 comments

Comments

@tbo
Copy link

tbo commented Jun 19, 2016

In certain situations emacs doesn't properly paste text. Apparently this only happens if the current buffer isn't saved and both web-mode and evil-mode are loaded. I was able to reproduce this behavior with the following config:

(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
(package-initialize)
(require 'evil)
(evil-mode 1)
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.js\\'" . web-mode))

Reproduction:

Edit the following file:

function test() {
    console.log('hello world');
}

Then press the following series of keys:

yGPwywp (Copy the function in front of the cursor, go to the function name, copy it behind the cursor)

Result:

function test() {
tes
    console.log('hello world');
}
function test() {
    console.log('hello world');
}

Apparently the text has been truncated and is being pasted in the next line.
If I remove web-mode (the last two lines) from my config, then everything works as expected:

function ttestest() {
    console.log('hello world');
}
function test() {
    console.log('hello world');
}

Here is the output of web-mode-debug:

Loading /usr/share/emacs/site-lisp/site-start.d/autoconf-init.el (source)...done
Loading /usr/share/emacs/site-lisp/site-start.d/cmake-init.el (source)...done
Loading /usr/share/emacs/site-lisp/site-start.d/desktop-entry-mode-init.el (source)...done
Loading /usr/share/emacs/site-lisp/site-start.d/git-init.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a.
test.js has auto save data; consider M-x recover-this-file
 [2 times]
--- WEB-MODE DEBUG BEG ---
versions: emacs(25.0) web-mode("14.0.8")
vars: engine("none") minor("none") content-type("javascript") file("/home/tbo/test.js")
system: window(nil) config("x86_64-redhat-linux-gnu")
colors: fg(nil) bg(nil)
minor modes: (completion-in-region-mode global-eldoc-mode evil-local-mode evil-mode undo-tree-mode global-undo-tree-mode shell-dirtrack-mode)
vars:
web-mode-enable-current-column-highlight=nil
web-mode-enable-current-element-highlight=nil
indent-tabs-mode=t
--- WEB-MODE DEBUG END ---
@fxbois
Copy link
Owner

fxbois commented Jun 19, 2016

Hi, i do not use evil and would prefer you see this directly with them. I can provide help if needed

@tbo
Copy link
Author

tbo commented Jun 19, 2016

I wasn't quite able to reproduce the problem without evil-mode. Multiple ways could lead to the output, that is generated by the listed evil commands. It might as well be a problem in evil. Do you have suggestions on how to further debug this?

@fxbois
Copy link
Owner

fxbois commented Jun 26, 2016

@tbo sorry but I am not able to help you on this. Perhaps try on emacs stackoverflow

@ctjhoa
Copy link

ctjhoa commented Nov 30, 2016

I can confirm this issue and it's very annoying.

@tbo
Copy link
Author

tbo commented Jan 22, 2017

I tried to find some help on Stackoverflow and the Evil issue tracker, but haven't got a single answer within the past 6 months:

http://emacs.stackexchange.com/questions/24542/pasting-text-doesnt-work-properly-in-evil-web-mode
emacs-evil/evil#703
(BTW: evil moved to github a few days ago and as result the dates are wrong)

It seems that spacemacs users are affected by this problem as well:

syl20bnr/spacemacs#3960

I tried to debug this even further and found something curious while testing different combinations of web-/evil-/js2-mode. These are the outputs of (thing-at-point 'word) with the marker set on the freshly copied test in my test case above.

evil-mode + web-mode:

#("test" 0 4 (yank-handler (evil-yank-line-handler) part-side javascript face web-mode-function-name-face))

evil-mode only:

#("test" 0 4 (fontified t face font-lock-function-name-face))

web-mode only:

#("test" 0 4 (part-side javascript face web-mode-function-name-face))

evil-mode + js2-mode:

#("test" 0 4 (fontified t font-lock-face font-lock-function-name-face))

Vanilla emacs:

#("test" 0 4 (fontified t face font-lock-function-name-face))

As you can see only the combination of web-mode and evil-mode looks totally out of place. The fact that it works with js2-mode might suggest that it is a problem in web-mode. I tried to look into to the web-mode sources, but was a bit overwhelmed.
@fxbois Do you have any suggestions what I could do to narrow this down?

@tbo
Copy link
Author

tbo commented Feb 19, 2017

@fxbois Are you watching closed issues?

@fxbois
Copy link
Owner

fxbois commented Feb 20, 2017

@tbo I can provide help on this but not more. I am not an evil-mode user

@tbo
Copy link
Author

tbo commented Feb 28, 2017

@fxbois I'm fine with that. I will continue my debugging efforts, but I'm unfamiliar with the internals of web-mode. I would appreciate some hints on where to start. Maybe even some references to emacs to concepts I should get familiar with.

@bschwehn
Copy link

As far as I can tell, this is caused by a combination of

a) evil leaving the (yank-handler (evil-yank-line-handler) property after a line yank
b) web mode setting yank-excluded-properties to t

@fxbois
Copy link
Owner

fxbois commented Sep 13, 2017

@bschwehn do you suggest any change in the web-mode code/behaviour ?

@bschwehn
Copy link

@fxbois: I don't understand this issue well enough to suggest any change.

Actually, after trying again, I am not sure anymore that the yank-excluded-properties related code in web-mode really makes a difference.

For now, this looks more like an issue in evil to me

@wasamasa
Copy link

For the record, this has been resolved in Evil recently: emacs-evil/evil#937

@fxbois
Copy link
Owner

fxbois commented Oct 21, 2017

Thank you very much for the update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants