Skip to content

Commit

Permalink
[Fix #778] sp-skip-closing-pair cleans up after jumping out of sexp.
Browse files Browse the repository at this point in the history
This is the same as invoking sp-up-sexp in the same context (which is
used to perform the jump internally anyway).
  • Loading branch information
Fuco1 committed Oct 5, 2017
1 parent bebfdfb commit 456b78c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
8 changes: 7 additions & 1 deletion smartparens.el
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,12 @@ The whitespace between the closing delimiter and last \"thing\"
inside the expression is removed. It works analogically for the
`sp-backward-up-sexp'.
Note that this also happens when `sp-skip-closing-pair' is
invoked (usually in strict mode when the closing delimiter is
typed) as it calls `sp-up-sexp' internally. This behaviour can
be customized by various settings of `sp-autoskip-closing-pair'
and `sp-autoskip-opening-pair'.
If the mode is in the list \"interactive\", only reindent the sexp
if the command was called interactively. This is recommended for
general use.
Expand Down Expand Up @@ -3943,7 +3949,7 @@ achieve this by using `sp-pair' or `sp-local-pair' with
(< (point) :end-in)))
(if test-only t
(delete-char -1)
(sp-up-sexp)))))
(sp-up-sexp nil t)))))
(unless (or test-only
sp-buffer-modified-p)
(set-buffer-modified-p nil))
Expand Down
14 changes: 14 additions & 0 deletions test/smartparens-skip-closing-pair-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ executing `sp-skip-closing-pair'."
(execute-kbd-macro "[]|")
(should (equal (buffer-string) "from sys import stdin, \\\n stdout\n\na = \"[]|\""))))

;; #778
(ert-deftest sp-test-reindent-after-skip-closing-pair-in-strict-mode ()
(sp-test-with-temp-elisp-buffer "(foo\n | \n)"
(smartparens-strict-mode 1)
(execute-kbd-macro ")")
(sp-buffer-equals "(foo)|")))

;; #778
(ert-deftest sp-test-reindent-after-skip-closing-pair-with-autoskip-disabled ()
(sp-test-with-temp-elisp-buffer "(foo\n | \n)"
(let ((sp-autoskip-closing-pair nil))
(execute-kbd-macro ")")
(sp-buffer-equals "(foo\n )| \n)"))))

;; #421
;; If we are in a balanced context and hit a closing delimiter for
;; an autoskip pair which is not enclosing (so we would jump out of
Expand Down

0 comments on commit 456b78c

Please sign in to comment.