Handle dead snippets better

* yasnippet-debug.el (yas-debug-live-marker)
(yas-debug-ov-fom-start, yas-debug-ov-fom-end)
(yas-debug-live-range, yas--debug-format-fom-concise): Don't assume
snippet has markers, it could have been converted to integer position.
This commit is contained in:
Noam Postavsky 2017-05-16 21:37:04 -04:00
parent 2f5cb2e2ef
commit 7b03ac2030

View File

@ -95,8 +95,10 @@
(color-ov (yas-debug-get-live-indicator marker)) (color-ov (yas-debug-get-live-indicator marker))
(color (car color-ov)) (color (car color-ov))
(ov (cdr color-ov)) (ov (cdr color-ov))
(decorator (overlay-get ov 'before-string))) (decorator (overlay-get ov 'before-string))
(propertize (format "at %d" (marker-position marker)) (str (format "at %d" (+ marker))))
(if (markerp marker)
(propertize str
'cursor-sensor-functions 'cursor-sensor-functions
`(,(lambda (window _oldpos dir) `(,(lambda (window _oldpos dir)
(overlay-put (overlay-put
@ -104,16 +106,17 @@
(propertize decorator (propertize decorator
'face (if (eq dir 'entered) 'face (if (eq dir 'entered)
'mode-line-highlight color))))) 'mode-line-highlight color)))))
'face color))) 'face color)
str)))
(defun yas-debug-ov-fom-start (ovfom) (defun yas-debug-ov-fom-start (ovfom)
(if (overlayp ovfom) (overlay-start ovfom) (cond ((overlayp ovfom) (overlay-start ovfom))
(let ((m (yas--fom-start ovfom))) ((integerp ovfom) ovfom)
(when (markerp m) (marker-position m))))) (t (yas--fom-start ovfom))))
(defun yas-debug-ov-fom-end (ovfom) (defun yas-debug-ov-fom-end (ovfom)
(if (overlayp ovfom) (overlay-end ovfom) (cond ((overlayp ovfom) (overlay-end ovfom))
(let ((m (yas--fom-end ovfom))) ((integerp ovfom) ovfom)
(when (markerp m) (marker-position m))))) (t (yas--fom-end ovfom))))
(defun yas-debug-live-range (range) (defun yas-debug-live-range (range)
(let* ((color-ov (yas-debug-get-live-indicator range)) (let* ((color-ov (yas-debug-get-live-indicator range))
@ -123,8 +126,8 @@
(decorator-end (overlay-get ov 'after-string)) (decorator-end (overlay-get ov 'after-string))
(beg (yas-debug-ov-fom-start range)) (beg (yas-debug-ov-fom-start range))
(end (yas-debug-ov-fom-end range))) (end (yas-debug-ov-fom-end range)))
(if (and beg end) (if (and beg end (not (integerp beg)) (not (integerp end)))
(propertize (format "from %d to %d" beg end) (propertize (format "from %d to %d" (+ beg) (+ end))
'cursor-sensor-functions 'cursor-sensor-functions
`(,(lambda (window _oldpos dir) `(,(lambda (window _oldpos dir)
(let ((face (if (eq dir 'entered) (let ((face (if (eq dir 'entered)
@ -278,15 +281,15 @@
(cond ((yas--field-p fom) (cond ((yas--field-p fom)
(format "field %s from %d to %d" (format "field %s from %d to %d"
(yas--field-number fom) (yas--field-number fom)
(marker-position (yas--field-start fom)) (+ (yas--field-start fom))
(marker-position (yas--field-end fom)))) (+ (yas--field-end fom))))
((yas--mirror-p fom) ((yas--mirror-p fom)
(format "mirror from %d to %d" (format "mirror from %d to %d"
(marker-position (yas--mirror-start fom)) (+ (yas--mirror-start fom))
(marker-position (yas--mirror-end fom)))) (+ (yas--mirror-end fom))))
(t (t
(format "snippet exit at %d" (format "snippet exit at %d"
(marker-position (yas--fom-start fom))))))) (+ (yas--fom-start fom)))))))
(defun yas-debug-process-command-line (&optional options) (defun yas-debug-process-command-line (&optional options)
"Implement command line processing." "Implement command line processing."