emacs-evil / evil-surround

you will be surrounded (surround.vim for evil, the extensible vi layer)
Other
627 stars 60 forks source link

Emacs 26 fails two tests: function and tag surround with dot repeat #131

Closed duianto closed 6 years ago

duianto commented 6 years ago

Description

Two tests fail in Emacs 26.0.50: (ert-info ("more examples from readme: function surrounding with dot repeat") and (ert-info ("even more examples from readme: tag surrounding with dot repeat")

The other tests in evil-surround-test.el pass in Emacs 26, and all tests pass in Emacs 25.3.1.

System Info

Steps to reproduce

  1. Download this file: https://github.com/emacs-evil/evil/blob/master/evil-test-helpers.el and move it into the .emacs.d/ directory.
  2. Start Emacs 26.0.50
  3. Open a new buffer: press C-x b type: test press: RET
  4. Switch to M-x evil-mode RET
  5. Switch to M-x emacs-lisp-mode
  6. Copy and paste the following lines, into the test buffer:
    
    (add-to-list 'load-path "~/.emacs.d/")

(require 'evil-test-helpers)

(ert-deftest evil-surround-test () (ert-info ("more examples from readme: function surrounding with dot repeat") (evil-test-buffer :visual-start nil :visual-end nil "argument1 argument2" (turn-on-evil-surround-mode) ("ysiwffunction" [return]) "function(argument1) argument2" ("W.") "function(argument1) function(argument2)")) (ert-info ("even more examples from readme: tag surrounding with dot repeat") (evil-test-buffer :visual-start nil :visual-end nil "tag1 tag2" (turn-on-evil-surround-mode) ("ysiw") "tag1 tag2" ("W.") "tag1 tag2")))

(ert 'evil-surround-test)


7. Evaluate the buffer `M-x` `eval-buffer` `RET`

The first test fails:

F evil-surround-test Info: more examples from readme: function surrounding with dot repeat (ert-test-failed ((should (string= (buffer-substring (point) (min ... ...)) after)) :form (string= "function(argument1) functioniwf(argumen" "function(argument1) function(argument2)") :value nil))

`"function(argument1) functioniwf(argumen"`
`iwf` has been inserted between the second instance of `function` and `(`, and the last three characters `t2)` are missing.

8. Select the lines in the first test:

(ert-info ("more examples from readme: function surrounding with dot repeat") (evil-test-buffer :visual-start nil :visual-end nil "argument1 argument2" (turn-on-evil-surround-mode) ("ysiwffunction" [return]) "function(argument1) argument2" ("W.") "function(argument1) function(argument2)"))

9. Comment them `M-;`
10. Evaluate the buffer again `M-x` `eval-buffer` `RET`

Now the second test fails:

F evil-surround-test Info: even more examples from readme: tag surrounding with dot repeat (ert-test-failed ((should (string= (buffer-substring (point) (min ... ...)) after)) :form (string= "tag1 <aiw<>tag2<" "tag1 tag2") :value nil))


`"<a>tag1</a> <aiw<>tag2<"`
`iw<` has been inserted between the `<a` and `>tag2`, and the last three characters `/a>` are missing.

#### Replicating the tests manually
1. Open a new buffer `C-x b` `manually` `RET`
2. Enable `M-x` `evil-surround-mode` `RET`
3. Type: `argument1 argument2`
4. Place the cursor on the first `a`
5. Press: `ysiwffunction` `RET`
it works as expected so far: `function(argument1) argument2`
6. Press: `W.`
This results in: `function(argument1) functioniwf(argument2)`

`iwf` has been inserted here as well, but the last three characters `t2)` haven't been deleted.

7. On a newline, type: `tag1 tag2`
8. Move the cursor to the first `t`
9. Press: `ysiw<a>`
it works as expected: `<a>tag1</a> tag2`
10. Press `W.`
This results in: `<a>tag1</a> <aiw<>tag2</aiw>`

`iw<` has been inserted between `<a` and `>tag2`, and `iw` has been inserted before the last `>`.
No characters have been deleted.

#### Emacs 25.3.1
Both tests pass, when the same tests are evaluated in Emacs 25.3.1.

When they are tested manually:
`argument1 argument2` results in: `function(argument1) function(argument2)`
and
`tag1 tag2` results in: `<a>tag1</a> <a>tag2</a>`

As expected.
ninrod commented 6 years ago

hum... interesting. Will take a look at this. I'll summon @justbur which is the author of the fix. I've just written these tests. Maybe some api breakage from emacs 25 t o26. which is odd.

justbur commented 6 years ago

I'm guessing it's related to this change, https://github.com/emacs-mirror/emacs/commit/dc9c6a071c0c12be2bd490f85107486bca44623e#diff-eae606e7f95addb6efcd3f7703a53658. I'll look into it.

ninrod commented 6 years ago

@justbur, I've just ran the tests into emacs git HEAD. it is confirmed

ninrod commented 6 years ago

thanks @duianto, should be fixed in the next melpa build. @justbur, perfect work as always. Thanks!

duianto commented 6 years ago

It's working now, thanks.