Skip to content

Commit

Permalink
[Fix #758] Correctly show delimiters from inside.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuco1 committed Jun 24, 2017
1 parent 6182efa commit 0f32a87
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 8 deletions.
4 changes: 2 additions & 2 deletions smartparens.el
Original file line number Diff line number Diff line change
Expand Up @@ -8964,10 +8964,10 @@ support custom pairs."
(sp-get ok
(when (or (and back
(or (= :end (point))
(= :end-in (point))))
(= :beg-in (point))))
(and (not back)
(or (= :beg (point))
(= :beg-in (point)))))
(= :end-in (point)))))
(sp-show--pair-create-overlays :beg :end :op-l :cl-l)))
(if back
(sp-show--pair-create-mismatch-overlay (- (point) (length match))
Expand Down
91 changes: 85 additions & 6 deletions test/smartparens-show-mode-test.el
Original file line number Diff line number Diff line change
@@ -1,10 +1,89 @@
(require 'smartparens)
(require 'evil)

(ert-deftest sp-test-show-mode-point-at-nonpairable-stringlike-delimiter-textmode ()
(let ((sp-pairs '((t . ((:open "\"" :close "\"" :actions (insert wrap autoskip navigate))
(:open "'" :close "'" :actions (insert wrap autoskip navigate)))))))
(sp-test-with-temp-buffer "\"asdasd'| asdasd asd\""
(text-mode)
(show-smartparens-mode 1)
(sp-show--pair-function)
(should (eq sp-show-pair-overlays nil)))))
(:open "'" :close "'" :actions (insert wrap autoskip navigate))))))
(sp-show-pair-overlays nil))
(unwind-protect
(sp-test-with-temp-buffer "\"asdasd'| asdasd asd\""
(text-mode)
(show-smartparens-mode 1)
(sp-show--pair-function)
(should (eq sp-show-pair-overlays nil)))
(sp-show--pair-delete-overlays))))

(ert-deftest sp-test-show-mode-point-at-beg-of-sexp ()
(let ((sp-pairs '((t . ((:open "(" :close ")" :actions (insert wrap autoskip navigate))))))
(sp-show-pair-overlays nil))
(unwind-protect
(sp-test-with-temp-elisp-buffer "|(foo bar)"
(show-smartparens-mode 1)
(sp-show--pair-function)
(should (not (eq sp-show-pair-overlays nil))))
(sp-show--pair-delete-overlays))))

(ert-deftest sp-test-show-mode-point-at-end-of-sexp ()
(let ((sp-pairs '((t . ((:open "(" :close ")" :actions (insert wrap autoskip navigate))))))
(sp-show-pair-overlays nil))
(unwind-protect
(sp-test-with-temp-elisp-buffer "(foo bar)|"
(show-smartparens-mode 1)
(sp-show--pair-function)
(should (not (eq sp-show-pair-overlays nil))))
(sp-show--pair-delete-overlays))))

(ert-deftest sp-test-show-mode-point-at-beg-in-of-sexp-from-inside-t ()
(let ((sp-pairs '((t . ((:open "(" :close ")" :actions (insert wrap autoskip navigate))))))
(sp-show-pair-overlays nil)
(sp-show-pair-from-inside t))
(unwind-protect
(sp-test-with-temp-elisp-buffer "(|foo bar)"
(show-smartparens-mode 1)
(sp-show--pair-function)
(should (not (eq sp-show-pair-overlays nil))))
(sp-show--pair-delete-overlays))))

(ert-deftest sp-test-show-mode-point-at-end-in-sexp-from-inside-t ()
(let ((sp-pairs '((t . ((:open "(" :close ")" :actions (insert wrap autoskip navigate))))))
(sp-show-pair-overlays nil)
(sp-show-pair-from-inside t))
(unwind-protect
(sp-test-with-temp-elisp-buffer "(foo bar|)"
(show-smartparens-mode 1)
(sp-show--pair-function)
(should (not (eq sp-show-pair-overlays nil))))
(sp-show--pair-delete-overlays))))

(ert-deftest sp-test-show-mode-point-at-beg-in-of-sexp-from-inside-nil ()
(let ((sp-pairs '((t . ((:open "(" :close ")" :actions (insert wrap autoskip navigate))))))
(sp-show-pair-overlays nil)
(sp-show-pair-from-inside nil))
(unwind-protect
(sp-test-with-temp-elisp-buffer "(|foo bar)"
(show-smartparens-mode 1)
(sp-show--pair-function)
(should (eq sp-show-pair-overlays nil)))
(sp-show--pair-delete-overlays))))

(ert-deftest sp-test-show-mode-point-at-end-in-sexp-from-inside-nil ()
(let ((sp-pairs '((t . ((:open "(" :close ")" :actions (insert wrap autoskip navigate))))))
(sp-show-pair-overlays nil)
(sp-show-pair-from-inside nil))
(unwind-protect
(sp-test-with-temp-elisp-buffer "(foo bar|)"
(show-smartparens-mode 1)
(sp-show--pair-function)
(should (eq sp-show-pair-overlays nil)))
(sp-show--pair-delete-overlays))))

(ert-deftest sp-test-show-mode-point-at-end-in-sexp-evil ()
(let ((sp-pairs '((t . ((:open "(" :close ")" :actions (insert wrap autoskip navigate))))))
(sp-show-pair-overlays nil))
(unwind-protect
(sp-test-with-temp-elisp-buffer "(foo bar|)"
(evil-local-mode)
(show-smartparens-mode 1)
(sp-show--pair-function)
(should (not (eq sp-show-pair-overlays nil))))
(sp-show--pair-delete-overlays))))

0 comments on commit 0f32a87

Please sign in to comment.