|
49 | 49 | :group 'helm-fuzzy) |
50 | 50 |
|
51 | 51 |
|
| 52 | + |
| 53 | +(defun helm-fuzzy--flatten-list (l) |
| 54 | + "Flatten the multiple dimensional array, L to one dimensonal array." |
| 55 | + (cond ((null l) nil) |
| 56 | + ((atom l) (list l)) |
| 57 | + (t (loop for a in l appending (helm-fuzzy--flatten-list a))))) |
| 58 | + |
| 59 | +(defun helm-fuzzy--get-faces (pos) |
| 60 | + "Get the font faces at POS." |
| 61 | + (helm-fuzzy--flatten-list |
| 62 | + (remq nil |
| 63 | + (list |
| 64 | + (get-char-property pos 'read-face-name) |
| 65 | + (get-char-property pos 'face) |
| 66 | + (plist-get (text-properties-at pos) 'face))))) |
| 67 | + |
| 68 | +(defun helm-fuzzy--is-current-point-face (in-face) |
| 69 | + "Check if current face the same face as IN-FACE." |
| 70 | + (let ((faces (helm-fuzzy--get-faces (point)))) |
| 71 | + (if (listp faces) |
| 72 | + (if (equal (cl-position in-face faces :test 'string=) nil) |
| 73 | + ;; If return nil, mean not found in the `faces' list. |
| 74 | + nil |
| 75 | + ;; If have position, meaning the face exists. |
| 76 | + t) |
| 77 | + (string= in-face faces)))) |
| 78 | + |
52 | 79 | (defun helm-fuzzy--is-contain-list-string (in-list in-str) |
53 | 80 | "Check if a string IN-STR contain in any string in the string list IN-LIST." |
54 | 81 | (cl-some #'(lambda (lb-sub-str) (string-match-p (regexp-quote lb-sub-str) in-str)) in-list)) |
|
62 | 89 | (save-selected-window |
63 | 90 | (select-window (active-minibuffer-window)) |
64 | 91 | (setq pattern (buffer-string)) |
65 | | - (setq pos (string-match-p helm-pattern pattern)) |
| 92 | + (save-excursion |
| 93 | + (goto-char (point-min)) |
| 94 | + (while (and (< (point) (length pattern)) |
| 95 | + (= pos -1)) |
| 96 | + (forward-char 1) |
| 97 | + (unless (helm-fuzzy--is-current-point-face "helm-minibuffer-prompt") |
| 98 | + (setq pos (1- (point)))))) |
66 | 99 | (setq pattern (substring pattern pos (length pattern))))) |
67 | 100 | pattern)) |
68 | 101 |
|
|
0 commit comments