Skip to content

Commit

Permalink
バグ修正
Browse files Browse the repository at this point in the history
  • Loading branch information
Haruma-K committed Dec 22, 2023
1 parent 9ffd095 commit 39de7a3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private void SetHierarchy(int entryItemId)

if (!_folderPathToItemIdMap.ContainsKey(currentFolderPath))
{
var folderItem = new PaletteEditorTreeViewFolderItem(folderName)
var folderItem = new PaletteEditorTreeViewFolderItem(currentFolderPath)
{
id = _currentItemId++,
displayName = folderName
Expand Down Expand Up @@ -180,10 +180,24 @@ public void SetFolderMode(bool folderMode, bool reload = true)
public void RemoveItem(string entryId, bool invokeCallback = true)
{
var id = _entryIdToItemIdMap[entryId];
var item = GetItem(id);
_entryIdToItemIdMap.Remove(entryId);
RemoveItem(id, invokeCallback);
RemoveParentItemsIfEmpty(item);
}

private void RemoveParentItemsIfEmpty(TreeViewItem item)
{
var parent = item.parent;
if (parent.id != -1 && !parent.hasChildren)
{
var folderItem = (PaletteEditorTreeViewFolderItem)parent;
_folderPathToItemIdMap.Remove(folderItem.FolderPath);
RemoveItem(parent.id, false);
RemoveParentItemsIfEmpty(parent);
}
}

protected override bool CanRename(TreeViewItem item)
{
// Rename is not supported for folder.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ namespace uPalette.Editor.Core.PaletteEditor
{
internal sealed class PaletteEditorTreeViewFolderItem : TreeViewItem
{
public PaletteEditorTreeViewFolderItem(string name)
public PaletteEditorTreeViewFolderItem(string folderPath)
{
Name = name;
FolderPath = folderPath;
}

public string Name { get; }
public string FolderPath { get; }
}
}

0 comments on commit 39de7a3

Please sign in to comment.