Fix #200: Helm mode line is mixedly active/inactive when previewing a line.

This commit is contained in:
Vincent Zhang 2019-07-25 03:20:37 +08:00
parent e2e8c1c422
commit 1834cf687d

View file

@ -2188,13 +2188,18 @@ The cdr can also be a function that returns a name to use.")
(doom-modeline-def-segment helm-buffer-id (doom-modeline-def-segment helm-buffer-id
"Helm session identifier." "Helm session identifier."
(when (bound-and-true-p helm-alive-p) (when (bound-and-true-p helm-alive-p)
(let ((active (doom-modeline--active)))
(concat (concat
(doom-modeline-spc) (doom-modeline-spc)
(doom-modeline-icon-fileicon "elisp" :height 1.0 :v-adjust -0.15 (doom-modeline-icon-fileicon "elisp"
:face (if doom-modeline-major-mode-color-icon :height 1.0
:v-adjust -0.15
:face (if active
(if doom-modeline-major-mode-color-icon
'all-the-icons-purple 'all-the-icons-purple
'mode-line)) 'mode-line)
(if doom-modeline-icon (doom-modeline-spc)) 'mode-line-inactive))
(when doom-modeline-icon (doom-modeline-spc))
(propertize (propertize
(let ((custom (cdr (assoc (buffer-name) doom-modeline--helm-buffer-ids))) (let ((custom (cdr (assoc (buffer-name) doom-modeline--helm-buffer-ids)))
(case-fold-search t) (case-fold-search t)
@ -2204,30 +2209,37 @@ The cdr can also be a function that returns a name to use.")
(t (t
(string-match "\\*helm:? \\(mode \\)?\\([^\\*]+\\)\\*" name) (string-match "\\*helm:? \\(mode \\)?\\([^\\*]+\\)\\*" name)
(concat "HELM " (capitalize (match-string 2 name)))))) (concat "HELM " (capitalize (match-string 2 name))))))
'face 'doom-modeline-buffer-file) 'face (if active' doom-modeline-buffer-file 'mode-line-inactive))
(doom-modeline-spc)))) (doom-modeline-spc)))))
(doom-modeline-def-segment helm-number (doom-modeline-def-segment helm-number
"Number of helm candidates." "Number of helm candidates."
(when (bound-and-true-p helm-alive-p) (when (bound-and-true-p helm-alive-p)
(let ((active (doom-modeline--active)))
(concat (concat
(propertize (format " %d/%d" (propertize (format " %d/%d"
(helm-candidate-number-at-point) (helm-candidate-number-at-point)
(helm-get-candidate-number t)) (helm-get-candidate-number t))
'face 'doom-modeline-buffer-path) 'face (if active 'doom-modeline-buffer-path 'mode-line-inactive))
(propertize (format " (%d total) " (helm-get-candidate-number)) (propertize (format " (%d total) " (helm-get-candidate-number))
'face 'doom-modeline-info)))) 'face (if active 'doom-modeline-info 'mode-line-inactive))))))
(doom-modeline-def-segment helm-help (doom-modeline-def-segment helm-help
"Helm keybindings help." "Helm keybindings help."
(when (bound-and-true-p helm-alive-p) (when (bound-and-true-p helm-alive-p)
(let ((active (doom-modeline--active)))
(-interleave (-interleave
(mapcar (lambda (s) (mapcar (lambda (s)
(propertize (substitute-command-keys s) 'face 'doom-modeline-buffer-file)) (propertize (substitute-command-keys s)
'face (if active
'doom-modeline-buffer-file
'mode-line-inactive)))
'("\\<helm-map>\\[helm-help]" '("\\<helm-map>\\[helm-help]"
"\\<helm-map>\\[helm-select-action]" "\\<helm-map>\\[helm-select-action]"
"\\<helm-map>\\[helm-maybe-exit-minibuffer]/F1/F2...")) "\\<helm-map>\\[helm-maybe-exit-minibuffer]/F1/F2..."))
'("(help) " "(actions) " "(action) ")))) (mapcar (lambda (s)
(propertize s 'face (if active 'mode-line 'mode-line-inactive)))
'("(help) " "(actions) " "(action) "))))))
(doom-modeline-def-segment helm-prefix-argument (doom-modeline-def-segment helm-prefix-argument
"Helm prefix argument." "Helm prefix argument."
@ -2235,7 +2247,10 @@ The cdr can also be a function that returns a name to use.")
helm--mode-line-display-prefarg) helm--mode-line-display-prefarg)
(let ((arg (prefix-numeric-value (or prefix-arg current-prefix-arg)))) (let ((arg (prefix-numeric-value (or prefix-arg current-prefix-arg))))
(unless (= arg 1) (unless (= arg 1)
(propertize (format "C-u %s" arg) 'face 'doom-modeline-info))))) (propertize (format "C-u %s" arg)
'face (if (doom-modeline--active)
'doom-modeline-info
'mode-line-inactive))))))
(defvar doom-modeline--helm-current-source nil (defvar doom-modeline--helm-current-source nil
"The currently active helm source.") "The currently active helm source.")
@ -2244,7 +2259,9 @@ The cdr can also be a function that returns a name to use.")
(when (and (bound-and-true-p helm-alive-p) (when (and (bound-and-true-p helm-alive-p)
doom-modeline--helm-current-source doom-modeline--helm-current-source
(eq 1 (cdr (assq 'follow doom-modeline--helm-current-source)))) (eq 1 (cdr (assq 'follow doom-modeline--helm-current-source))))
"HF")) (propertize "HF" 'face (if (doom-modeline--active)
'mode-line
'mode-line-inactive))))
;; ;;
;; git timemachine ;; git timemachine