Skip to content

Commit

Permalink
Fix helm-occur transformer issue #2526
Browse files Browse the repository at this point in the history
Avoid empty or nil candidates while not breaking nearest position.
  • Loading branch information
thierryvolpiatto committed Jun 28, 2022
1 parent 0f905a6 commit 7cd4a46
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions helm-occur.el
Original file line number Diff line number Diff line change
Expand Up @@ -252,17 +252,22 @@ engine beeing completely different and also much faster."
(defun helm-occur-transformer (candidates source)
"Return CANDIDATES prefixed with line number."
(cl-loop with buf = (helm-get-attr 'buffer-name source)
for c in candidates collect
(when (string-match helm-occur--search-buffer-regexp c)
(let ((linum (match-string 1 c))
(disp (match-string 2 c)))
(cons (format "%s:%s"
(propertize
linum 'face 'helm-grep-lineno
'help-echo (buffer-file-name
(get-buffer buf)))
disp)
(string-to-number linum))))))
for c in candidates
for disp-linum = (when (string-match helm-occur--search-buffer-regexp c)
(let ((linum (match-string 1 c))
(disp (match-string 2 c)))
(list
linum
(format "%s:%s"
(propertize
linum 'face 'helm-grep-lineno
'help-echo (buffer-file-name
(get-buffer buf)))
disp))))
for linum = (car disp-linum)
for disp = (cadr disp-linum)
when (and disp (not (string= disp "")))
collect (cons disp (string-to-number linum))))

(defclass helm-moccur-class (helm-source-in-buffer)
((buffer-name :initarg :buffer-name
Expand Down

0 comments on commit 7cd4a46

Please sign in to comment.