fix directory rename from disk

This commit is contained in:
Matt Parker
2025-10-21 19:03:35 +10:00
parent 4496f44a21
commit fb489ec429
4 changed files with 7 additions and 4 deletions

View File

@@ -24,7 +24,7 @@ public class IdeFileExternalChangeHandler
// TODO: Test - this most likely only will ever be called on linux - windows and macos(?) does delete + create on rename of folders
private async Task OnFolderRenamed(string oldFolderPath, string newFolderPath)
{
var sharpIdeFolder = SolutionModel.AllFolders.SingleOrDefault(f => f.Path == newFolderPath);
var sharpIdeFolder = SolutionModel.AllFolders.SingleOrDefault(f => f.Path == oldFolderPath);
if (sharpIdeFolder is null)
{
return;

View File

@@ -10,7 +10,6 @@ public partial class RenameDirectoryDialog : ConfirmationDialog
private LineEdit _nameLineEdit = null!;
public SharpIdeFolder Folder { get; set; } = null!;
public TreeItem FolderTreeItem { get; set; } = null!;
[Inject] private readonly IdeFileOperationsService _ideFileOperationsService = null!;
@@ -61,7 +60,6 @@ public partial class RenameDirectoryDialog : ConfirmationDialog
_ = Task.GodotRun(async () =>
{
await _ideFileOperationsService.RenameDirectory(Folder, directoryName);
await this.InvokeAsync(() => FolderTreeItem.SetText(0, directoryName));
});
QueueFree();
}

View File

@@ -78,7 +78,6 @@ public partial class SolutionExplorerPanel
{
var renameDirectoryDialog = _renameDirectoryDialogScene.Instantiate<RenameDirectoryDialog>();
renameDirectoryDialog.Folder = folder;
renameDirectoryDialog.FolderTreeItem = folderTreeItem;
AddChild(renameDirectoryDialog);
renameDirectoryDialog.PopupCentered();
}

View File

@@ -213,6 +213,12 @@ public partial class SolutionExplorerPanel : MarginContainer
folderItem.SetIcon(0, FolderIcon);
folderItem.SetMetadata(0, new RefCountedContainer<SharpIdeFolder>(sharpIdeFolder));
Observable.EveryValueChanged(sharpIdeFolder, folder => folder.Name)
.Skip(1).SubscribeAwait(async (s, ct) =>
{
await this.InvokeAsync(() => folderItem.SetText(0, s));
}).AddTo(this);
// Observe subfolders
var subFoldersView = sharpIdeFolder.Folders.CreateView(y => new TreeItemContainer());
subFoldersView.Unfiltered.ToList().ForEach(s => s.View.Value = CreateFolderTreeItem(_tree, folderItem, s.Value));