Skip to content

Commit

Permalink
fix: Set directory to active directory or the working directory if no…
Browse files Browse the repository at this point in the history
… folder selected (new-file)
  • Loading branch information
tomlin7 authored Apr 13, 2024
1 parent 6e6d7f5 commit d901395
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions biscuit/core/components/views/sidebar/explorer/directorytree.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,23 +177,12 @@ def new_file(self, filename) -> None:
if not filename:
return

parent = self.selected_directory()

if not parent:
# This condition is necessary to avoid a edge case where the user might
# try to create a new file without a folder opened, causing self.selected_directory()
# to return None

# TODO Let the user know that the file was not created because no folder was selected

print("New file not created because user did not select a folder.")
return

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 in that directory,
# open an editor for the existing file
# 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

Expand Down

0 comments on commit d901395

Please sign in to comment.