aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--evil-common.el14
-rw-r--r--evil-tests.el14
2 files changed, 22 insertions, 6 deletions
diff --git a/evil-common.el b/evil-common.el
index 3e586c0..d48d2f5 100644
--- a/evil-common.el
+++ b/evil-common.el
@@ -3096,14 +3096,18 @@ selection matches that object exactly."
(goto-char (cdr op-end))
(when (and (zerop (funcall thing +1)) (match-beginning 0))
(setq cl-end (cons (match-beginning 0) (match-end 0)))))
- ;; use the tighter one of both
+ ;; Bug #607: use the tightest selection that contains the
+ ;; original selection. If non selection contains the original,
+ ;; use the larger one.
(cond
((and (not op) (not cl-end))
(error "No surrounding delimiters found"))
- ((or (not op) ; first not found
- (and cl-end ; second better
- (>= (car op-end) (car op))
- (<= (cdr cl-end) (cdr cl))))
+ ((or (not op) ; first not found
+ (and cl-end ; second found
+ (>= (car op-end) (car op)) ; second smaller
+ (<= (cdr cl-end) (cdr cl))
+ (<= (car op-end) beg) ; second contains orig
+ (>= (cdr cl-end) end)))
(setq op op-end cl cl-end)))
(setq op-end op cl-end cl) ; store copy
;; if the current selection contains the surrounding
diff --git a/evil-tests.el b/evil-tests.el
index 60134ec..de80008 100644
--- a/evil-tests.el
+++ b/evil-tests.el
@@ -6249,7 +6249,19 @@ Below some empty line."))
(evil-test-buffer
"(([\"]\"))\n"
("dab")
- "([)]\n")))
+ "([)]\n"))
+ (ert-info ("Enlarge to smallest complete surrounding")
+ (evil-test-buffer
+ "for (auto i : vector) {
+ if (c<ond) {
+ do_[s]>omething();
+ }
+}"
+ ("i}")
+ "for (auto i : vector) {<
+ if (cond) {
+ do_something();
+ }[\n]>}")))
(ert-deftest evil-test-forces-linewise-text-objects ()
"Test `evil-text-object-change-visual-type' option."