ui/neotree: fix open/find-this-file commands #992

A not-so-recent update to projectile caused doom-project-root's
signature to change (it can now return nil, if not in a project). This
fixes +neotree/open and +neotree/find-this-file to account for this new
behavior, by resorting to default-directory in the absence of a project.
This commit is contained in:
Henrik Lissner 2018-10-31 14:45:51 -04:00
parent 4063b8d14a
commit 8085a55bcb
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -8,18 +8,19 @@
(defun +neotree/open () (defun +neotree/open ()
"Open the neotree window in the current project." "Open the neotree window in the current project."
(interactive) (interactive)
(let ((project-root (doom-project-root))) (require 'neotree)
(require 'neotree) (if (neo-global--window-exists-p)
(if (neo-global--window-exists-p) (neotree-hide)
(neotree-hide) (neotree-dir (or (doom-project-root)
(neotree-dir project-root)))) default-directory))))
;;;###autoload ;;;###autoload
(defun +neotree/find-this-file () (defun +neotree/find-this-file ()
"Open the neotree window in the current project, and find the current file." "Open the neotree window in the current project, and find the current file."
(interactive) (interactive)
(let ((path buffer-file-name) (let ((path buffer-file-name)
(project-root (doom-project-root))) (project-root (or (doom-project-root)
default-directory)))
(require 'neotree) (require 'neotree)
(cond ((and (neo-global--window-exists-p) (cond ((and (neo-global--window-exists-p)
(get-buffer-window neo-buffer-name t)) (get-buffer-window neo-buffer-name t))