ui/doom-dashboard: fix edge cases where cwd wasn't set properly
This commit is contained in:
parent
13111ff5c4
commit
538e4c52bd
1 changed files with 24 additions and 15 deletions
|
@ -117,20 +117,27 @@ whose dimensions may not be fully initialized by the time this is run."
|
||||||
s))
|
s))
|
||||||
|
|
||||||
(defun +doom-dashboard--get-pwd (dir)
|
(defun +doom-dashboard--get-pwd (dir)
|
||||||
(cond ((null +doom-dashboard-pwd-policy)
|
(let ((lastcwd +doom-dashboard--last-cwd)
|
||||||
default-directory)
|
(policy +doom-dashboard-pwd-policy))
|
||||||
(dir dir)
|
(cond ((null policy)
|
||||||
((null +doom-dashboard--last-cwd)
|
default-directory)
|
||||||
default-directory)
|
(dir dir)
|
||||||
(+doom-dashboard--last-cwd
|
((null lastcwd)
|
||||||
(when-let* ((default-directory +doom-dashboard--last-cwd))
|
default-directory)
|
||||||
(pcase +doom-dashboard-pwd-policy
|
((eq policy 'last-project)
|
||||||
(`last-project (doom-project-root))
|
(let ((cwd default-directory)
|
||||||
(`last default-directory)
|
(default-directory lastcwd))
|
||||||
((pred stringp) (expand-file-name +doom-dashboard-pwd-policy))
|
(if (doom-project-p)
|
||||||
((pred functionp) (funcall +doom-dashboard-pwd-policy default-directory))
|
(doom-project-root)
|
||||||
(_ (warn "`+doom-dashboard-pwd-policy' has an invalid value of '%s'"
|
cwd)))
|
||||||
+doom-dashboard-pwd-policy)))))))
|
((eq policy 'last))
|
||||||
|
((stringp policy)
|
||||||
|
(expand-file-name policy lastcwd))
|
||||||
|
((functionp policy)
|
||||||
|
(funcall policy lastcwd))
|
||||||
|
(t
|
||||||
|
(warn "`+doom-dashboard-pwd-policy' has an invalid value of '%s'"
|
||||||
|
+doom-dashboard-pwd-policy)))))
|
||||||
|
|
||||||
(defun +doom-dashboard-reload (&optional dir)
|
(defun +doom-dashboard-reload (&optional dir)
|
||||||
"Update the DOOM scratch buffer (or create it, if it doesn't exist)."
|
"Update the DOOM scratch buffer (or create it, if it doesn't exist)."
|
||||||
|
@ -143,7 +150,9 @@ whose dimensions may not be fully initialized by the time this is run."
|
||||||
(unless (eq major-mode '+doom-dashboard-mode)
|
(unless (eq major-mode '+doom-dashboard-mode)
|
||||||
(+doom-dashboard-mode))
|
(+doom-dashboard-mode))
|
||||||
(erase-buffer)
|
(erase-buffer)
|
||||||
(setq default-directory (+doom-dashboard--get-pwd dir))
|
(setq default-directory
|
||||||
|
(or (+doom-dashboard--get-pwd dir)
|
||||||
|
default-directory))
|
||||||
(let ((+doom-dashboard--height (window-height (get-buffer-window fallback-buffer)))
|
(let ((+doom-dashboard--height (window-height (get-buffer-window fallback-buffer)))
|
||||||
(lines 1)
|
(lines 1)
|
||||||
content)
|
content)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue