Просмотр исходного кода

Bugfix: Fix Library rename not working when initialized from the context menu

BearishSun 6 лет назад
Родитель
Сommit
90a5d26cd5
2 измененных файлов с 37 добавлено и 36 удалено
  1. 36 35
      Source/EditorManaged/Windows/Library/LibraryWindow.cs
  2. 1 1
      Source/bsf

+ 36 - 35
Source/EditorManaged/Windows/Library/LibraryWindow.cs

@@ -289,55 +289,56 @@ namespace bs.Editor
                         MoveSelection(MoveDirection.Right);
                     }
                 }
-                else
-                {
-                    if (Input.IsButtonDown(ButtonCode.Return))
-                    {
-                        string newName = inProgressRenameElement.GetRenamedName();
+            }
+            else
+            {
+                if (isRenameInProgress && !HasFocus)
+                    StopRename();
+            }
 
-                        string originalPath = inProgressRenameElement.path;
-                        originalPath = originalPath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
+            if (isRenameInProgress)
+            {
+                if (Input.IsButtonDown(ButtonCode.Return))
+                {
+                    string newName = inProgressRenameElement.GetRenamedName();
 
-                        string newPath = Path.GetDirectoryName(originalPath);
-                        string newNameWithExtension = newName + Path.GetExtension(originalPath);
-                        newPath = Path.Combine(newPath, newNameWithExtension);
+                    string originalPath = inProgressRenameElement.path;
+                    originalPath = originalPath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
 
-                        bool renameOK = true;
-                        if (!PathEx.IsValidFileName(newName))
-                        {
-                            DialogBox.Open(new LocEdString("Error"), new LocEdString("The name you specified is not a valid file name. Try another."), DialogBox.Type.OK);
-                            renameOK = false;
-                        }
+                    string newPath = Path.GetDirectoryName(originalPath);
+                    string newNameWithExtension = newName + Path.GetExtension(originalPath);
+                    newPath = Path.Combine(newPath, newNameWithExtension);
 
-                        if (renameOK)
-                        {
-                            // Windows sees paths with dot at the end as if they didn't have it
-                            // so remove the dot to ensure the project library does the same
-                            string trimmedNewPath = newPath.TrimEnd('.');
+                    bool renameOK = true;
+                    if (!PathEx.IsValidFileName(newName))
+                    {
+                        DialogBox.Open(new LocEdString("Error"), new LocEdString("The name you specified is not a valid file name. Try another."), DialogBox.Type.OK);
+                        renameOK = false;
+                    }
 
-                            if (originalPath != trimmedNewPath && ProjectLibrary.Exists(trimmedNewPath))
-                            {
-                                DialogBox.Open(new LocEdString("Error"), new LocEdString("File/folder with that name already exists in this folder."), DialogBox.Type.OK);
-                                renameOK = false;
-                            }
-                        }
+                    if (renameOK)
+                    {
+                        // Windows sees paths with dot at the end as if they didn't have it
+                        // so remove the dot to ensure the project library does the same
+                        string trimmedNewPath = newPath.TrimEnd('.');
 
-                        if (renameOK)
+                        if (originalPath != trimmedNewPath && ProjectLibrary.Exists(trimmedNewPath))
                         {
-                            ProjectLibrary.Rename(originalPath, newNameWithExtension);
-                            StopRename();
+                            DialogBox.Open(new LocEdString("Error"), new LocEdString("File/folder with that name already exists in this folder."), DialogBox.Type.OK);
+                            renameOK = false;
                         }
                     }
-                    else if (Input.IsButtonDown(ButtonCode.Escape))
+
+                    if (renameOK)
                     {
+                        ProjectLibrary.Rename(originalPath, newNameWithExtension);
                         StopRename();
                     }
                 }
-            }
-            else
-            {
-                if (isRenameInProgress && !HasFocus)
+                else if (Input.IsButtonDown(ButtonCode.Escape))
+                {
                     StopRename();
+                }
             }
 
             if (autoScrollAmount != 0)

+ 1 - 1
Source/bsf

@@ -1 +1 @@
-Subproject commit 0ddf18017f6b98478998f87f53f8178d0763a9ce
+Subproject commit 7befbd669b6a3f391f02ac17af44cf25b3c2eb96