fix directory rename from disk
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -78,7 +78,6 @@ public partial class SolutionExplorerPanel
|
||||
{
|
||||
var renameDirectoryDialog = _renameDirectoryDialogScene.Instantiate<RenameDirectoryDialog>();
|
||||
renameDirectoryDialog.Folder = folder;
|
||||
renameDirectoryDialog.FolderTreeItem = folderTreeItem;
|
||||
AddChild(renameDirectoryDialog);
|
||||
renameDirectoryDialog.PopupCentered();
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user