                        :face 'doom-modeline-urgent
                        :v-adjust -0.05)
                       " "))
-            (let ((dir-path  (+doom-modeline--buffer-path))
-                  (faces (or faces (if active 'doom-modeline-buffer-path))))
-              (when dir-path
-                (if faces
-                    (propertize dir-path 'face `(:inherit ,faces))
-                  dir-path)))
-            (let ((file-path (+doom-modeline--buffer-file))
-                  (faces (or faces (if active 'doom-modeline-buffer-file))))
-              (if faces
+            (when-let (dir-path (+doom-modeline--buffer-path))
+              (if-let (faces (or faces (if active 'doom-modeline-buffer-path)))
+                  (propertize dir-path 'face `(:inherit ,faces))
+                dir-path))
+            (when-let (file-path (+doom-modeline--buffer-file))
+              (if-let (faces (or faces (if active 'doom-modeline-buffer-file)))
                   (propertize file-path 'face `(:inherit ,faces))
                 file-path)))))
 

(def-modeline-segment! buffer-info
  "Combined information about the current buffer, including the current working
directory, the file name, and its state (modified, read-only or non-existent)."
  (let ((all-the-icons-scale-factor 1.2)
        (modified-p (buffer-modified-p))
        (active (active))
        faces)
    (if modified-p (push 'doom-modeline-buffer-modified faces))
    (concat (if buffer-read-only
                (concat (all-the-icons-octicon
                         "lock"

(defun +doom-modeline--buffer-file ()
  "Display the base of the current buffer's filename."
  (if buffer-file-name
      (file-name-nondirectory (or buffer-file-truename (file-truename buffer-file-name)))
    "%b"))

(defun +doom-modeline--buffer-path ()
