Add support for indexing and auto-completing story notes

This commit is contained in:
Veronica Berglyd Olsen
2025-05-18 22:36:25 +02:00
parent f2f2e6cb46
commit f22f80dafd
3 changed files with 25 additions and 4 deletions
+10 -1
View File
@@ -618,6 +618,10 @@ class Index:
"""Return all story structure keys."""
return self._itemIndex.allStoryKeys()
def getNoteKeys(self) -> set[str]:
"""Return all note comment keys."""
return self._itemIndex.allNoteKeys()
def novelStructure(
self, rootHandle: str | None = None, activeOnly: bool = True
) -> Iterable[tuple[str, str, str, IndexHeading]]:
@@ -920,11 +924,12 @@ class IndexCache:
which provides lookup capabilities and caching for shared data.
"""
__slots__ = ("story", "tags")
__slots__ = ("note", "story", "tags")
def __init__(self, tagsIndex: TagsIndex) -> None:
self.tags: TagsIndex = tagsIndex
self.story: set[str] = set()
self.note: set[str] = set()
return
@@ -979,6 +984,10 @@ class ItemIndex:
"""Return all story structure keys."""
return self._cache.story.copy()
def allNoteKeys(self) -> set[str]:
"""Return all note comment keys."""
return self._cache.note.copy()
def allItemTags(self, tHandle: str) -> list[str]:
"""Get all tags set for headings of an item."""
if tHandle in self._items: