emacs-evil / evil

The extensible vi layer for Emacs.
GNU General Public License v3.0
3.39k stars 280 forks source link

Emacs search for blank line won't work backwards #1158

Open mohkale opened 5 years ago

mohkale commented 5 years ago

Issue type

The title explain it pretty well, but the problem here is I can search for blank lines using the regexp "/^ *$" and it can search forward, but it won't search backwards. I tried opening the same file and searching using the same regexp in neovim & in it you can search forward and backward so I can only surmise this is a bug in evil.

[X] Bug report [ ] Enhancement request [ ] Question [ ] Other

Environment

Emacs version: GNU Emacs 26.1 (build 1, x86_64-w64-mingw32) of 2018-05-30 Operating System: Windows 10 Evil version: Evil version evil-git-8c0b8c344 Evil installation type: MELPA (auto installed via spacemacs) Graphical/Terminal: GUI Tested in a make emacs session (see CONTRIBUTING.md): No

Reproduction steps

Expected behavior

I should be able to move to previous results.

Actual behavior

I can move to results further forward, but not backward.

Further notes

nnicandro commented 5 years ago

This has to do with the fact that searching backwards eventually uses re-search-backward. You will get the same result if you run (re-search-backward "^ *$"). See the note in its doc string. You can get around its limitations for this particular case by using "^ +$", unless you also want to match empty lines.

mohkale commented 5 years ago

Understood, I was aware it would work if I changed '*' to '+' but seeing as the behaviour in vim and evil are different and I was under the impression if anything differs between the 2 then it's considered a bug, I opened this issue anyways. @dzop is there any intention to change this behaviour at all to better emulate vim?

nnicandro commented 5 years ago

If someone can come up with an acceptable way to fix this on the lisp side then maybe it will be fixed in Evil, but I think the proper way would be to fix re-search-backward on the C level.