Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve editor stats handling and test coverage #1725

Merged
merged 5 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions novelwriter/core/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,16 @@ def checkType(self, tHandle: str, itemType: nwItemType) -> bool:
return False
return tItem.itemType == itemType

def getItemPath(self, tHandle: str) -> list[str]:
def getItemPath(self, tHandle: str, asName: bool = False) -> list[str]:
"""Iterate upwards in the tree until we find the item with
parent None, the root item, and return the list of handles.
We do this with a for loop with a maximum depth to make
infinite loops impossible.
parent None, the root item, and return the list of handles, or
alternatively item names. We do this with a for loop with a
maximum depth to make infinite loops impossible.
"""
tTree = []
tItem = self.__getitem__(tHandle)
if tItem is not None:
tTree.append(tHandle)
tTree.append(tItem.itemName if asName else tHandle)
for _ in range(MAX_DEPTH):
if tItem.itemParent is None:
return tTree
Expand All @@ -370,7 +370,7 @@ def getItemPath(self, tHandle: str) -> list[str]:
if tItem is None:
return tTree
else:
tTree.append(tHandle)
tTree.append(tItem.itemName if asName else tHandle)
else:
raise RecursionError("Critical internal error")

Expand Down
Loading
Loading