Skip to content

Commit 74d1683

Browse files
committed
Filter out bogus locations in the occurrences reply for Xref
For some reason, the occurrences command output sometimes contains bogus locations (line 0, col -1). It really shouldn't, but filter them out until that has been fixed (#1410).
1 parent ea6693e commit 74d1683

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

emacs/merlin-xref.el

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,19 @@
2626
(widen)
2727
(let ((locations
2828
;; Transform the result into a list of (START END START-LINE).
29-
(mapcar
29+
(mapcan
3030
(lambda (loc)
3131
(let* ((start-line-col (cdr (assq 'start loc)))
32-
(start-line (cdr (assq 'line start-line-col)))
33-
(end-line-col (cdr (assq 'end loc)))
34-
(start (merlin-xref--line-col-to-pos start-line-col))
35-
(end (merlin-xref--line-col-to-pos end-line-col)))
36-
(list start end start-line)))
32+
(start-line (cdr (assq 'line start-line-col))))
33+
;; We sometimes get bogus locations (line 0, col -1)
34+
;; in the reply. That should be fixed, but meanwhile
35+
;; filter them out (issue #1410).
36+
(and (> start-line 0)
37+
(let* ((end-line-col (cdr (assq 'end loc)))
38+
(start
39+
(merlin-xref--line-col-to-pos start-line-col))
40+
(end (merlin-xref--line-col-to-pos end-line-col)))
41+
(list (list start end start-line))))))
3742
(let ((pt (get-text-property 0 'merlin-xref-point symbol)))
3843
(when pt
3944
(goto-char pt))

0 commit comments

Comments
 (0)