evil
evil copied to clipboard
Error with global delete pattern matching
Issue type
- Bug report
This is a report linked to https://github.com/radian-software/straight.el/issues/1015. While there may be some degree to which the behavior with straight differs from package.el a second user using emacs 29 was able to reproduce the actual (incorrect) behavior using either package manager. So it seemed reasonable to suspect this is an evil problem.
Environment
Emacs version: 28.2 but seems to also occur in emacs 29
Operating System: Arch Linux
Evil version: 1.15.0
Evil installation type: Melpa
Graphical/Terminal: Graphical
Tested in a make emacs
session (see CONTRIBUTING.md): Tested in Emacs -Q, has been repdocued by second user.
Reproduction steps
- Start emacs -Q
- load the evil-debug-straight.el file below
- eval the buffer
Interpretation
This is a test of the pattern matching in ex using global commands. The relevant command that is in error is:
:g/\{/+1,/\}/-1d
The example text in question is:
const something = {
a: 'x',
b: 'x',
c: 'x',
d: 'x',
}
const else = {
a: 'x',
b: 'x',
c: 'x',
d: 'x',
}
const c = 'bar'
const a = 'hello'
const b = 'foo'
Expected behavior
Should open a new buffer showing:
const something = {
}
const else = {
}
const c = 'bar'
const a = 'hello'
const b = 'foo'
Actual behavior
opens new buffer showing
a: 'x',
b: 'x',
c: 'x',
d: 'x',
}
a: 'x',
b: 'x',
c: 'x',
d: 'x',
}
const c = 'bar'
const a = 'hello'
const b = 'foo'
Futher Notes
I think it is something specific to the delete command as I noticed that the following works as expected (when I change the ordering of some of the relevant rows so there is something non-trivial to sort):
:g/\{/+1,/\}/-1 sort
Reprex script
;; Set up package.el to work with MELPA
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 6))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'evil)
(require 'evil)
(evil-mode 1)
(setq evil-ex-search-vim-style-regexp t)
(evil-select-search-module 'evil-search-module 'evil-search)
(switch-to-buffer "foo")
(insert "const something = {
a: 'x',
b: 'x',
c: 'x',
d: 'x',
}
const else = {
a: 'x',
b: 'x',
c: 'x',
d: 'x',
}
const c = 'bar'
const a = 'hello'
const b = 'foo'")
(evil-ex "g/\\{/+1,/\\}/-1d")
Thanks for the bug report. I'm almost certain that will have been caused by https://github.com/emacs-evil/evil/commit/e0e68d006320557a34c72102cd08c421fbf68ce5 which inadvertently ended support for offset search patterns for global delete. I will (partially, hopefully) revert and report back here. Apologies for the inconvenience.