Fix #515; only clear field on self-insert

* yasnippet.el (yas--on-field-overlay-modification): Only clear field if
  `this-command' is `self-insert-command'.  Clean up docstring.

Close #639.
This commit is contained in:
Noam Postavsky 2015-12-13 00:38:09 -05:00
parent 71f0142eda
commit 17fe7904ae

View File

@ -3385,9 +3385,8 @@ Move the overlay, or create it if it does not exit."
(defun yas--on-field-overlay-modification (overlay after? _beg _end &optional _length) (defun yas--on-field-overlay-modification (overlay after? _beg _end &optional _length)
"Clears the field and updates mirrors, conditionally. "Clears the field and updates mirrors, conditionally.
Only clears the field if it hasn't been modified and it point it Only clears the field if it hasn't been modified and point is at
at field start. This hook doesn't do anything if an undo is in field start. This hook does nothing if an undo is in progress."
progress."
(unless (or yas--inhibit-overlay-hooks (unless (or yas--inhibit-overlay-hooks
(not (overlayp yas--active-field-overlay)) ; Avoid Emacs bug #21824. (not (overlayp yas--active-field-overlay)) ; Avoid Emacs bug #21824.
(yas--undo-in-progress)) (yas--undo-in-progress))
@ -3399,7 +3398,8 @@ progress."
(yas--field-update-display field)) (yas--field-update-display field))
(yas--update-mirrors snippet)) (yas--update-mirrors snippet))
(field (field
(when (and (not (yas--field-modified-p field)) (when (and (eq this-command 'self-insert-command)
(not (yas--field-modified-p field))
(= (point) (yas--field-start field))) (= (point) (yas--field-start field)))
(yas--skip-and-clear field)) (yas--skip-and-clear field))
(setf (yas--field-modified-p field) t)))))) (setf (yas--field-modified-p field) t))))))