branch: elpa/helm
commit 3ca36e16dd80bd586e003e1cdcc30d77a38ce1a9
Author: Thierry Volpiatto <[email protected]>
Commit: Thierry Volpiatto <[email protected]>

    Use substring instead of regexp to extract display #2743
    
    Store the icon's length in icon property and extract display with
    substring from the length of icon + the space separator (assume we
    always use one space after icon).
---
 helm-core.el    | 3 +--
 helm-x-icons.el | 4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/helm-core.el b/helm-core.el
index 3acd40e869a..d5f19c7bd3d 100644
--- a/helm-core.el
+++ b/helm-core.el
@@ -2538,8 +2538,7 @@ when you want the `display-to-real' function(s) to be 
applied."
                        ((guard* (and (eq force-display-part 'noicon)
                                      (get-text-property 0 'icon it)))
                         ;; Remove icon if some from display see issue#2743.
-                        (replace-regexp-in-string
-                         "^[[:multibyte:]][ \t]+" "" it))
+                        (substring it (1+ guard))) ; icon length + one space.
                        (t it))))
              (src  (or source (helm-get-current-source)))
              (selection (helm-acond (force-display-part disp)
diff --git a/helm-x-icons.el b/helm-x-icons.el
index 354ba55aef5..6f13efa9b71 100644
--- a/helm-x-icons.el
+++ b/helm-x-icons.el
@@ -65,7 +65,7 @@ The returned alist is computed according to 
`helm-x-icons-provider'."
         icon)
     (when fn
       (setq icon (apply fn args))
-      (add-text-properties 0 1 '(icon t) icon)
+      (add-text-properties 0 1 `(icon ,(length icon)) icon)
       icon)))
 
 (defvar helm-x-icons-nerd-icons-compat-alist
@@ -160,7 +160,7 @@ and `helm-x-icons-nerd-icons-compat-alist'."
          (setq fn sym icon-name name)))))
     (when fn
       (setq icon (apply fn icon-name args))
-      (add-text-properties 0 1 '(icon t) icon)
+      (add-text-properties 0 1 `(icon ,(length icon)) icon)
       icon)))
 
 (provide 'helm-x-icons)

Reply via email to