porcupine
porcupine copied to clipboard
hiding nested projects
If I have two projects, ~/aoc/day6
and ~/aoc
, I can't hide aoc/day6
if a file named ~/aoc/day6/part2.py
is open. Maybe both projects should be hideable, because after hiding either one of them, the currently opened file can still be displayed as a part of the other project?
It should be something like this:
tree.contextmenu.add_command(
label="Hide this project",
command=on_click,
state="disabled" if tree.project_has_open_filetabs(project_id) # and the file(s) of
# the opened tab is not contained in any other visible project
else "normal",
)
Let's say that this check is implemented: we hide /aoc/day6
which before this check could not be hidden. /aoc
, instead, could've been hidden because its tree.project_has_open_filetabs(project_id)
returned false
so we should transfer the ownership of the tab to /aoc
.
Actually this is not possible in the way porcupine is organized since every opened tab is child of its first parent directory which automatically becomes a project. Maybe I'm wrong but I've never seen a project having a an opened tab of a file with 'depth=2' since if we try to do it the 'depth=1' dir will become project. Probably it's ok like it is now.
Maybe I'm wrong but I've never seen a project having a an opened tab of a file with 'depth=2' since if we try to do it the 'depth=1' dir will become project.
Porcupine tries to be more clever than this (see find_project_root
in utils.py). In short, it looks for a folder named .git
, README files, and a few other things, falling back to the parent directory when nothing else is found.
Nested projects are a mess, but also necessary. Before nested projects, the project of a file like /home/akuli/asdf.py
was /home/akuli
, and the project of /home/akuli/porcu/README.md
was also /home/akuli
, because /home/akuli/porcu
would have been a nested project and that wasn't a thing yet. So my home folder basically become one huge project that sucked all other projects inside it.
Cool, I did never try before using git repos or readme files (etc.) so I never experienced this. I looked at this, now I have clearer ideas. But wouldn't implementing that check brake this behaviour?
The project root, as shown in the directory tree, is not necessarily what find_project_root()
returns. There are already ways how those can end up different, for example, if you delete or create a README file that find_project_root()
relies on. As I said, this is a mess.
Ahah Yeah I see. But it seems to work btw.