|
|
@@ -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)
|