Skip to content

Commit

Permalink
Reset memoization on change
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronjensen committed Jul 20, 2016
1 parent 56c5b74 commit bcedebe
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions smartparens.el
Expand Up @@ -1356,6 +1356,12 @@ sexp, otherwise the call may be very slow."
(let ((p (or p (point))))
(if (eq p (sp-state-last-syntax-ppss-point sp-state))
(sp-state-last-syntax-ppss-result sp-state)
;; Add hook to reset memoization if necessary
(unless (or
(sp-state-last-syntax-ppss-point sp-state)
(sp-state-last-syntax-ppss-point sp-state))
(add-hook 'before-change-functions
'sp--reset-memoization t t))
(setf (sp-state-last-syntax-ppss-point sp-state) p
(sp-state-last-syntax-ppss-result sp-state) (syntax-ppss p)))))

Expand Down Expand Up @@ -2428,7 +2434,6 @@ should be highlighted."
"Remove all pair overlays that doesn't have point inside them,
are of zero length, or if point moved backwards."
;; if the point moved backwards, remove all overlays
(sp--reset-memoization)
(if (and sp-cancel-autoskip-on-backward-movement
(< (point) sp-previous-point))
(dolist (o sp-pair-overlay-list) (sp--remove-overlay o))
Expand All @@ -2441,7 +2446,7 @@ are of zero length, or if point moved backwards."
(when sp-pair-overlay-list
(setq sp-previous-point (point))))

(defun sp--reset-memoization ()
(defun sp--reset-memoization (&rest ignored)
"Reset memoization as a safety precaution."
(setf (sp-state-last-syntax-ppss-point sp-state) nil
(sp-state-last-syntax-ppss-result sp-state) nil))
Expand Down

0 comments on commit bcedebe

Please sign in to comment.