Skip to content

Commit

Permalink
fix: #756 Wrong buffer file name when it contains a percentage symbol…
Browse files Browse the repository at this point in the history
… "%"
  • Loading branch information
seagle0128 committed Dec 24, 2024
1 parent 4052840 commit 8f84545
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
17 changes: 8 additions & 9 deletions doom-modeline-core.el
Original file line number Diff line number Diff line change
Expand Up @@ -1459,10 +1459,11 @@ ARGS is same as `nerd-icons-octicon' and others."

(defun doom-modeline-display-text (text)
"Display TEXT in mode-line."
(if (doom-modeline--active)
text
(propertize text 'face `(:inherit (mode-line-inactive
,(get-text-property 0 'face text))))))
(let ((text (string-replace "%" "%%" text)))
(if (doom-modeline--active)
text
(propertize text 'face `(:inherit (mode-line-inactive
,(get-text-property 0 'face text)))))))

(defun doom-modeline-vcs-name ()
"Display the vcs name."
Expand Down Expand Up @@ -1598,7 +1599,7 @@ Return `default-directory' if no project was found."
('auto
(if (doom-modeline-project-p)
(doom-modeline--buffer-file-name buffer-file-name buffer-file-truename 'shrink 'shrink 'hide)
(propertize "%b" 'face 'doom-modeline-buffer-file)))
(propertize (buffer-name) 'face 'doom-modeline-buffer-file)))
('truncate-upto-project
(doom-modeline--buffer-file-name buffer-file-name buffer-file-truename 'shrink))
('truncate-from-project
Expand Down Expand Up @@ -1628,10 +1629,8 @@ Return `default-directory' if no project was found."
(propertize (file-name-nondirectory buffer-file-name)
'face 'doom-modeline-buffer-file)))
((or 'buffer-name _)
(propertize "%b" 'face 'doom-modeline-buffer-file)))))
(propertize (if (string-empty-p file-name)
(propertize "%b" 'face 'doom-modeline-buffer-file)
file-name)
(propertize (buffer-name) 'face 'doom-modeline-buffer-file)))))
(propertize file-name
'mouse-face 'mode-line-highlight
'help-echo (concat buffer-file-truename
(unless (string= (file-name-nondirectory buffer-file-truename)
Expand Down
3 changes: 1 addition & 2 deletions doom-modeline-segments.el
Original file line number Diff line number Diff line change
Expand Up @@ -1685,8 +1685,7 @@ mouse-2: Show help for minor mode"
By default, this shows the information specified by `global-mode-string'."
(when (or doom-modeline-display-misc-in-all-mode-lines
(doom-modeline--segment-visible 'misc-info))
(doom-modeline-display-text
(string-replace "%" "%%" (format-mode-line mode-line-misc-info)))))
(doom-modeline-display-text (format-mode-line mode-line-misc-info))))


;;
Expand Down

0 comments on commit 8f84545

Please sign in to comment.