Skip to content

Commit

Permalink
Merge pull request #288 from vyshnav-vinod/fix/directory-tree-bug
Browse files Browse the repository at this point in the history
Fix #287
  • Loading branch information
tomlin7 authored Apr 13, 2024
2 parents 6b6f68e + d901395 commit 36ae81a
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,15 @@ def new_file(self, filename) -> None:
if not filename:
return

parent = self.selected_directory()
parent = self.selected_directory() or self.base.active_directory or os.path.abspath('.')
path = os.path.join(parent, filename)

if os.path.exists(path):
# If user tries to create a new file with the name of an existing file
# open that existing file in editor instead.
self.base.open_editor(path)
return

with open(path, 'w+') as f:
f.write("")
self.create_root(parent, self.nodes[parent])
Expand Down

0 comments on commit 36ae81a

Please sign in to comment.