summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLionel Henry <lionel.hry@gmail.com>2018-10-20 14:48:22 +0200
committerFilipe Silva <ninrod@users.noreply.github.com>2018-10-20 09:48:22 -0300
commit440d391c89a7f6d5a7a0c9486b0e8ac4fc7f43aa (patch)
treedf20d9dee73e280cb376f64ffc528e5f8399250b /test
parenta92151def9db892b4eaef687d1a7fbe5b97cc760 (diff)
Fix visible narrowing when surrounding within a field (#135)
* Fix visible narrowing when surrounding within a field * Test that buffer is widened before reading char
Diffstat (limited to 'test')
-rw-r--r--test/evil-surround-test.el27
1 files changed, 26 insertions, 1 deletions
diff --git a/test/evil-surround-test.el b/test/evil-surround-test.el
index 120bac5..df8a03f 100644
--- a/test/evil-surround-test.el
+++ b/test/evil-surround-test.el
@@ -14,6 +14,18 @@
?\[ '("[ " . " ]")
?\{ '("{ " . " }"))
+(defmacro test-widened-buffer (start cmds exp)
+ (declare (indent 0))
+ `(let (widened)
+ (evil-test-buffer
+ ,start
+ (turn-on-evil-surround-mode)
+ (cl-letf (((symbol-function #'widen)
+ (lambda () (setq widened t))))
+ (execute-kbd-macro ,(car cmds)))
+ ,exp)
+ (should widened)))
+
(ert-deftest evil-surround-test ()
(ert-info ("basic surrounding")
(evil-test-buffer
@@ -169,4 +181,17 @@
(turn-on-evil-surround-mode)
("cs`)")
"[(]this_is_a_backtick_surrounded_word)"
- )))
+ ))
+ (ert-info ("buffer is widened before reading char")
+ (test-widened-buffer
+ "`[w]ord`"
+ ("cs`)")
+ "[(]word)")
+ (test-widened-buffer
+ "`[w]ord`"
+ ("ds`")
+ "[w]ord")
+ (test-widened-buffer
+ "[w]ord"
+ ("ysiwb")
+ "[(]word)")))