Updated to Risa's changes
This commit is contained in:
@@ -47,15 +47,6 @@ public sealed class TemplateFileSystem : FileSystem<Template>, IDisposable, ISav
|
||||
_templateChanged.Unsubscribe(OnTemplateChange);
|
||||
}
|
||||
|
||||
// Search the entire filesystem for the leaf corresponding to a template.
|
||||
public bool FindLeaf(Template template, [NotNullWhen(true)] out Leaf? leaf)
|
||||
{
|
||||
leaf = Root.GetAllDescendants(ISortMode<Template>.Lexicographical)
|
||||
.OfType<Leaf>()
|
||||
.FirstOrDefault(l => l.Value == template);
|
||||
return leaf != null;
|
||||
}
|
||||
|
||||
private void OnTemplateChange(TemplateChanged.Type type, Template? template, object? data)
|
||||
{
|
||||
switch (type)
|
||||
@@ -76,14 +67,14 @@ public sealed class TemplateFileSystem : FileSystem<Template>, IDisposable, ISav
|
||||
|
||||
return;
|
||||
case TemplateChanged.Type.Deleted:
|
||||
if (FindLeaf(template, out var leaf1))
|
||||
if (TryGetValue(template, out var leaf1))
|
||||
Delete(leaf1);
|
||||
return;
|
||||
case TemplateChanged.Type.ReloadedAll:
|
||||
Reload();
|
||||
return;
|
||||
case TemplateChanged.Type.Renamed when data is string oldName:
|
||||
if (!FindLeaf(template, out var leaf2))
|
||||
if (!TryGetValue(template, out var leaf2))
|
||||
return;
|
||||
|
||||
var old = oldName.FixName();
|
||||
|
||||
Reference in New Issue
Block a user