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

Evil search bug breaks Spacemacs #10410

Closed
NightMachinery opened this issue Mar 1, 2018 · 48 comments
Closed

Evil search bug breaks Spacemacs #10410

NightMachinery opened this issue Mar 1, 2018 · 48 comments

Comments

@NightMachinery
Copy link

NightMachinery commented Mar 1, 2018

Description :octocat:

Evil search bug.

Reproduction guide 🪲 Observed behaviour: 👀 💔

  • Start Emacs
  • Search sth with '/'.
  • Without pressing 'RET' click on the main buffer.
  • The evil functionality is broken: pressing a single d deletes the line. (Essentially a lot of keys double-press.)
  • By clicking on the minibuffer and pressing RET you can make evil normal.
  • But if you delete the main buffer and then press RET, evil stays broken.
  • You have to restart emacs for it to work normally again.

Expected behaviour: ❤️ 😄
The search should be canceled when the minibuffer loses focus.

System Info 💻

  • OS: darwin
  • Emacs: 25.3.1
  • Spacemacs: 0.300.0
  • Spacemacs branch: develop (rev. 5c251f6)
  • Graphic display: t
  • Distribution: spacemacs
  • Editing style: vim
  • Completion: helm
  • Layers:
(vimscript
 (rust :variables rust-format-on-save t)
 crystal
 (haskell :variables haskell-enable-hindent t)
 html python
 (scala :variables scala-auto-insert-asterisk-in-comments t scala-use-unicode-arrows t scala-auto-insert-asterisk-in-comments t)
 autohotkey helm auto-completion emacs-lisp
 (ibuffer :variables ibuffer-group-buffers-by 'modes)
 coq emoji
 (unicode-fonts :variables unicode-fonts-force-multi-color-on-mac t)
 git
 (java :variables java-backend 'ensime)
 markdown org
 (shell :variables shell-default-height 30 shell-default-position 'bottom)
 spell-checking syntax-checking version-control osx racket clojure)
  • System configuration features: NOTIFY ACL LIBXML2 ZLIB TOOLKIT_SCROLL_BARS
@CeleritasCelery
Copy link
Contributor

I can't reproduce. But if you think you can reliably reproduce the error, file an issue upstream with evil.

@duianto
Copy link
Contributor

duianto commented Mar 6, 2018

I'm able to reproduce it:

  • Start Emacs
  • open .spacemacs: SPC f e d
  • open the search prompt: /
  • select the .spacemacs window: M-1

now d deletes the whole line, and y copies the whole line.

Switching back to the minibuffer SPC w b, and exiting ESC or confirming the previous search term RET, restores d and y's default behaviour of waiting for a motion.

I'm unable to make the issue permanent by deleting a buffer, and confirming the search term.
If I SPC b d delete the .spacemacs buffer. Then I'm still able to switch to the minibuffer SPC w b and can cancel/confirm the search prompt. Now d and y have been restored to their default behaviour.

After deleting the buffer and confirming the search, then the messages buffer shows:

Error in minibuffer-exit-hook (evil-ex-search-stop-session): (error "Selecting deleted buffer")
evil-ex-start-search: Selecting deleted buffer

System Info 💻

  • OS: windows-nt
  • Emacs: 25.3.1
  • Spacemacs: 0.300.0
  • Spacemacs branch: develop (rev. 0fa3658)
  • Graphic display: t
  • Distribution: spacemacs
  • Editing style: vim
  • Completion: helm
  • Layers:
(autohotkey helm emacs-lisp git org spell-checking treemacs version-control)
  • System configuration features: XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS MODULES

@NightMachinery
Copy link
Author

@duianto What should I do? File an issue with evil?

@duianto
Copy link
Contributor

duianto commented Mar 7, 2018

It doesn't seem to be an evil issue, because when I start Emacs, and just load evil, then the / search prompt disappears (gets canceled?), when the .spacemacs buffer is selected, with the mouse, or with C-x o. And both d and y expects a motion.

This is how I only loaded the evil package.

  • Start Emacs with the --quick argument to not load any configurations
  • Let Emacs know where the packages are located, by evaluating:
(setq package-user-dir "~/.emacs.d/elpa/25.3/develop/")
  • M-x package-initialize
  • M-: (require 'evil)
  • M-x evil-mode

@NightMachinery
Copy link
Author

@duianto any idea what’s wrong?

@duianto
Copy link
Contributor

duianto commented Mar 7, 2018

The evil package adds an minibuffer-exit-hook, when the evil-ex-search-start-session function is called.

(add-hook 'minibuffer-exit-hook #'evil-ex-search-stop-session)

source: https://github.com/emacs-evil/evil/blob/427cf5faa57e8794ac93f594dc3d1972e687a25a/evil-search.el#L873

I don't know what/if Spacemacs does something to negate the minibuffer-exit-hook.

@carloscheddar
Copy link

I've been having this issue for months and could never find out how I triggered it. I always restarted to fix it but it's good to know that I can exit the mini buffer instead.

@CeleritasCelery
Copy link
Contributor

could we just add that hook back?

@codygman
Copy link

codygman commented Mar 9, 2018 via email

@NightMachinery
Copy link
Author

NightMachinery commented Mar 9, 2018

@codygman I have never heard of bidi-reordering and so I shouldn't have disabled it in my setup.

@NightMachinery
Copy link
Author

I have found a workaround! Just set the evil-search-module to its default, 'isearch'. This might be a bug in evil itself, not in Spacemacs. @duianto Can you check if the bug exists with just evil loaded?

@duianto
Copy link
Contributor

duianto commented Mar 28, 2018

Changing the evil-search-module to isearch doesn't change anything for me.

In Spacemacs, the / search prompt remains in the minibuffer and d still deletes the current line.

With just Emacs and evil (as described in comment: #10410 (comment)), the / search prompt cancels, when a window is selected.

@NightMachinery
Copy link
Author

@duianto That's strange! My Emacs behaves just as #10410 (comment) when I have the module set to 'isearch', and when I change it to evil's internal search, the bug reappears for me.

@NightMachinery
Copy link
Author

@codygman @carloscheddar @CeleritasCelery Can you check this variable? #10410 (comment)

@davidpasztor
Copy link

I also have this issue, but can't find where I should set the evil-search-module. @NightMachinary could you please explain where this should be set?

@NightMachinery
Copy link
Author

@davidpasztor Do M-x customize like this:
image
Or put (setq evil-search-module 'isearch) in your user-config.

@NightMachinery
Copy link
Author

@davidpasztor Please provide feedback, if this works, we'll need to put it in Spacemacs itself.

@davidpasztor
Copy link

@NightMachinary thanks for your help, I put that in my user-config, then reload my spacemacs, but the issue still persists :(

@NightMachinery
Copy link
Author

NightMachinery commented May 20, 2018 via email

@davidpasztor
Copy link

@NightMachinary sadly customize didn't help either

@larebsyed
Copy link
Contributor

larebsyed commented May 24, 2018

I found a temporary fix by adding these line in my .spacemacs file

  (defun kill-minibuffer ()
    (interactive)
    (when (windowp (active-minibuffer-window))
      (evil-ex-search-exit)))

  (add-hook 'mouse-leave-buffer-hook #'kill-minibuffer)

edited by @syl20bnr to format the code snippet correctly

@syl20bnr
Copy link
Owner

syl20bnr commented Jun 1, 2018

@larebsyed I edited your post to better format the code snippet.

@dijonkitchen
Copy link
Contributor

Any updates on this? Should the temporary fix be incorporated in the latest branch?

@hjorvari
Copy link

hjorvari commented May 5, 2020

This is the most annoying thing ever but TIL you can just do <spc> <spc> exit-minibuffer and it will fix it. Should be in the FAQ imo.

@duianto
Copy link
Contributor

duianto commented May 6, 2020

#10410 (comment) ☝️

I have found a workaround! Just set the evil-search-module to its default, 'isearch'. This might be a bug in evil itself, not in Spacemacs.

@NightMachinary You seem to be right.

The issue also occurs without Spacemacs (just Emacs and https://github.com/emacs-evil/evil), when:

(setq evil-search-module 'evil-search)

is defined in init.el before:

(require 'evil)
(evil-mode 1)

In Spacemacs

I retested adding:

(setq evil-search-module 'evil-search)

to either the user-init or user-config sections, but the issue still occurs.

However the issue stops happening when: evil-search-module
is set to isearch with: M-x customize

(As you said in a later comment: #10410 (comment) ☝️)

@NightMachinery
Copy link
Author

@duianto What is very weird is that I regularly lose my customized settings. I don’t know exactly how it happens, but every once in a while I notice something I had customized has reset. That’s why I’ve been avoiding customizing settings and use direct setq commands.

@duianto
Copy link
Contributor

duianto commented May 7, 2020

There's an issue about customizations here:
spacemacs forgets all customizations made through customize / org-customize #10504

It's marked as fixed in develop, and at least for me, bmags reproduction steps: #10504 (comment)
of adding a custom fill-column setting, remains after restarting Emacs and installing a package.

Maybe there's some side case that the fix didn't catch. You could post a comment there that your still losing customizations.

@NightMachinery
Copy link
Author

@duianto I don't know when exactly was the last time I lost a customization. I noticed this one because it causes an annoying bug when using the mouse with evil search, but it's possible that the lost was for before the bug got fixed. I'll be sure to comment if I notice a new customization resetting though.

@allentiak
Copy link
Contributor

@NightMachinary Could you try reproducing this on current develop? (So we can verify this bug is still relevant.)

@NightMachinery
Copy link
Author

@allentiak I have switched to Doom, and have workarounds in my Spacemacs config regardless. Feel free to close the issue, someone will just comment if the issue still persists.

@allentiak
Copy link
Contributor

@duianto It seems this one can be safely closed :-)

@duianto
Copy link
Contributor

duianto commented Jul 4, 2020

Instead of closing this, let's fix it 😄

A PR has been opened upstream:
Exit search prompt on mouse leave minibuffer emacs-evil/evil#1330

@allentiak
Copy link
Contributor

Cool!
(In any case, fixing it would also close it ;-)

@nwilleyltk
Copy link

I can confirm that the issue still exists for me on the develop branch. The mini-buffer will stick with the search term, and while it is stuck, typing c or d will delete the entire line. Once the mini-buffer is closed using exit-minibuffer, it behaves normally.

@mabdh
Copy link

mabdh commented Jul 12, 2021

I can confirm that the issue still exists for me on the develop branch. The mini-buffer will stick with the search term, and while it is stuck, typing c or d will delete the entire line. Once the mini-buffer is closed using exit-minibuffer, it behaves normally.

This works for me. Thanks!

@lebensterben
Copy link
Contributor

@duianto
Since there's no update from upstream, we should can use advice-add to add a :after advice to for now.

duianto added a commit to duianto/spacemacs that referenced this issue Aug 20, 2021
problem
Evil search bug breaks Spacemacs syl20bnr#10410
syl20bnr#10410

Multiple evil bindings break:
when a evil search prompt is active: / or ?
and a window is selected with the mouse.

notes
This fix can be removed when/if the pending upstream PR is merged:
Exit search prompt on mouse leave minibuffer
emacs-evil/evil#1330
@duianto
Copy link
Contributor

duianto commented Aug 20, 2021

A PR with a possible fix has been opened:
Fix evil search prompt on mouse leave #15002

@lebensterben
Copy link
Contributor

Just merged the fix and updating the label to 'Fixed in develop' now.

@lebensterben
Copy link
Contributor

closing since it's fixed in upstream.

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

No branches or pull requests