Skip to content

Commit

Permalink
ensure parent directory exist before creating new file
Browse files Browse the repository at this point in the history
  • Loading branch information
wakeful committed Jan 9, 2017
1 parent f4c13c3 commit f66ca96
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 f66ca96

Please sign in to comment.