Skip to content

Commit

Permalink
Merge pull request #217 from wakeful/ensure-parent-directory-existence
Browse files Browse the repository at this point in the history
ensure parent directory exist before creating new file
  • Loading branch information
aborn authored Jan 10, 2017
2 parents 6f7c82b + f66ca96 commit d2ae6ac
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions neotree.el
Original file line number Diff line number Diff line change
Expand Up @@ -1861,6 +1861,8 @@ If the current node is the first node then the last node is selected."
(when (and is-file
(funcall neo-confirm-create-file (format "Do you want to create file %S ?"
filename)))
;; ensure parent directory exist before saving
(mkdir (substring filename 0 (+ 1 (position ?/ filename :from-end t))) t)
;; NOTE: create a empty file
(write-region "" nil filename)
(neo-buffer--save-cursor-pos filename)
Expand Down

0 comments on commit d2ae6ac

Please sign in to comment.