Skip to content

Commit 6fc8530

Browse files
committed
Impls get raw pattern from minibueffer.
1 parent 6809094 commit 6fc8530

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

helm-fuzzy.el

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,26 @@
5050
"Check if a string IN-STR contain in any string in the string list IN-LIST."
5151
(cl-some #'(lambda (lb-sub-str) (string-match-p (regexp-quote lb-sub-str) in-str)) in-list))
5252

53+
54+
(defun helm-fuzzy--find-pattern ()
55+
"Get the raw pattern directly from minibuffer."
56+
(let ((pattern "")
57+
(pos -1))
58+
(when (active-minibuffer-window)
59+
(select-window (active-minibuffer-window))
60+
(setq pattern (buffer-string))
61+
(setq pos (string-match-p helm-pattern pattern))
62+
(setq pattern (substring pattern pos (length pattern))))
63+
pattern))
64+
5365
(defun helm-fuzzy--sort-candidates (candidates)
5466
"Fuzzy matching for all CANDIDATES."
5567
(when (and (not (string= helm-pattern ""))
5668
(not (helm-fuzzy--is-contain-list-string helm-fuzzy-not-allow-fuzzy helm-buffer)))
5769
(require 'flx)
5870
(let* ((scoring-table (make-hash-table))
5971
(scoring-keys '())
60-
(first-sel (nth 0 candidates))
61-
(pattern (if (listp first-sel) (cdr first-sel) first-sel)))
72+
(pattern (helm-fuzzy--find-pattern)))
6273
(dolist (cand candidates)
6374
(let* ((cand-id (if (listp cand) (cdr cand) cand))
6475
(scoring (flx-score cand-id pattern))
@@ -90,6 +101,7 @@
90101
(setq candidates (helm-fuzzy--sort-candidates candidates))
91102
candidates))
92103

104+
93105
(defun helm-fuzzy--enable ()
94106
"Enable `helm-fuzzy'."
95107
(require 'helm)

0 commit comments

Comments
 (0)