From fb489ec42994a08ee771ed322d1547ea008677d6 Mon Sep 17 00:00:00 2001 From: Matt Parker <61717342+MattParkerDev@users.noreply.github.com> Date: Tue, 21 Oct 2025 19:03:35 +1000 Subject: [PATCH] fix directory rename from disk --- .../Features/FileWatching/IdeFileExternalChangeHandler.cs | 2 +- .../ContextMenus/Dialogs/RenameDirectoryDialog.cs | 2 -- .../SolutionExplorer/ContextMenus/FolderContextMenu.cs | 1 - .../Features/SolutionExplorer/SolutionExplorerPanel.cs | 6 ++++++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/SharpIDE.Application/Features/FileWatching/IdeFileExternalChangeHandler.cs b/src/SharpIDE.Application/Features/FileWatching/IdeFileExternalChangeHandler.cs index 1befe91..babea56 100644 --- a/src/SharpIDE.Application/Features/FileWatching/IdeFileExternalChangeHandler.cs +++ b/src/SharpIDE.Application/Features/FileWatching/IdeFileExternalChangeHandler.cs @@ -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; diff --git a/src/SharpIDE.Godot/Features/SolutionExplorer/ContextMenus/Dialogs/RenameDirectoryDialog.cs b/src/SharpIDE.Godot/Features/SolutionExplorer/ContextMenus/Dialogs/RenameDirectoryDialog.cs index 462a4d8..b948fd5 100644 --- a/src/SharpIDE.Godot/Features/SolutionExplorer/ContextMenus/Dialogs/RenameDirectoryDialog.cs +++ b/src/SharpIDE.Godot/Features/SolutionExplorer/ContextMenus/Dialogs/RenameDirectoryDialog.cs @@ -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(); } diff --git a/src/SharpIDE.Godot/Features/SolutionExplorer/ContextMenus/FolderContextMenu.cs b/src/SharpIDE.Godot/Features/SolutionExplorer/ContextMenus/FolderContextMenu.cs index 2d15a41..73dd87e 100644 --- a/src/SharpIDE.Godot/Features/SolutionExplorer/ContextMenus/FolderContextMenu.cs +++ b/src/SharpIDE.Godot/Features/SolutionExplorer/ContextMenus/FolderContextMenu.cs @@ -78,7 +78,6 @@ public partial class SolutionExplorerPanel { var renameDirectoryDialog = _renameDirectoryDialogScene.Instantiate(); renameDirectoryDialog.Folder = folder; - renameDirectoryDialog.FolderTreeItem = folderTreeItem; AddChild(renameDirectoryDialog); renameDirectoryDialog.PopupCentered(); } diff --git a/src/SharpIDE.Godot/Features/SolutionExplorer/SolutionExplorerPanel.cs b/src/SharpIDE.Godot/Features/SolutionExplorer/SolutionExplorerPanel.cs index 16f5a79..c22faf9 100644 --- a/src/SharpIDE.Godot/Features/SolutionExplorer/SolutionExplorerPanel.cs +++ b/src/SharpIDE.Godot/Features/SolutionExplorer/SolutionExplorerPanel.cs @@ -213,6 +213,12 @@ public partial class SolutionExplorerPanel : MarginContainer folderItem.SetIcon(0, FolderIcon); folderItem.SetMetadata(0, new RefCountedContainer(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));