fix: Reload on adding a file

This commit is contained in:
Dendy 2024-02-24 13:38:35 +01:00
parent 6af686f3bd
commit 2e8fdf67f1
1 changed files with 10 additions and 0 deletions

View File

@ -2,6 +2,9 @@ import os
import posixpath import posixpath
from typing import Self from typing import Self
# TODO: Cut any dependency of DocumentNode on the backend implementation
# Maybe use some king of "yield" to achieve this?
class DocumentNode(): class DocumentNode():
def __init__(self, name: str, children: list): def __init__(self, name: str, children: list):
@ -75,6 +78,11 @@ class DocumentTree():
def get_node(self, path: str) -> DocumentNode | None: def get_node(self, path: str) -> DocumentNode | None:
return self.root.get_child(path) return self.root.get_child(path)
def reload(self) -> bool:
# TODO: Instead of doing this, actually reload
self.root = DocumentNode.get_tree(self.base, '')
return True
# ----- Document Operations ----- # ----- Document Operations -----
# Split and remerge for Windows # Split and remerge for Windows
@ -93,4 +101,6 @@ class DocumentTree():
with open(internal_path, 'w') as file: with open(internal_path, 'w') as file:
file.write(text) file.write(text)
self.reload()
# ------------------------------- # -------------------------------