Skip to content

Commit

Permalink
FIX #48 If a single file is opened, pathview is not working
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlin7 committed Jun 21, 2023
1 parent 2106a22 commit 29f7fbe
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions biscuit/core/components/editors/breadcrumbs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,22 @@ def __init__(self, master, path=None, *args, **kwargs):

self.pathview = PathView(self)

path = os.path.relpath(path, self.base.active_directory).split('\\')
for i, item in enumerate(path):
text = item if item == path[-1] else f"{item} ›"
# if the file does not belong to active directory, use the absolute path instead
if not (self.base.active_directory and
os.path.commonpath([self.base.active_directory, path]) == os.path.abspath(self.base.active_directory)):
path = os.path.abspath(path).split('\\')
for i, item in enumerate(path):
text = item if item == path[-1] else f"{item} ›"

btn = Item(self, os.path.join(self.base.active_directory, "\\".join(path[:i])), text=text)
btn.bind("<Button-1>", self.pathview.show)
btn.pack(side=tk.LEFT)
btn = Item(self, "\\".join(path[:i]), text=text)
btn.bind("<Button-1>", self.pathview.show)
btn.pack(side=tk.LEFT)
else:
# otherwise use the relative path to active directory
path = os.path.relpath(path, self.base.active_directory).split('\\')
for i, item in enumerate(path):
text = item if item == path[-1] else f"{item} ›"

btn = Item(self, os.path.join(self.base.active_directory, "\\".join(path[:i])), text=text)
btn.bind("<Button-1>", self.pathview.show)
btn.pack(side=tk.LEFT)

0 comments on commit 29f7fbe

Please sign in to comment.