fix: only navigate on rename if the file you are renaming is the one you have loaded

This commit is contained in:
Kevin
2025-06-23 15:41:43 -05:00
parent 47fba02446
commit 9e16737ee2

View File

@ -376,7 +376,7 @@ export const ProjectExplorer = ({
applicationProjectDirectory
)
// create a file if it is fake
// create a file if it is fake and navigate to that file!
if (row.isFake) {
systemIOActor.send({
type: SystemIOMachineEvents.importFileFromURL,
@ -387,9 +387,14 @@ export const ProjectExplorer = ({
},
})
} else {
// rename the file otherwisejk
const requestedAbsoluteFilePathWithExtension = joinOSPaths(getParentAbsolutePath(
row.path
), name)
// If your router loader is within the file you are renaming then reroute to the new path on disk
// If you are renaming a file you are not loaded into, do not reload!
const shouldWeNavigate = requestedAbsoluteFilePathWithExtension === file?.path
systemIOActor.send({
type: SystemIOMachineEvents.renameFileAndNavigateToFile,
type: shouldWeNavigate ? SystemIOMachineEvents.renameFileAndNavigateToFile : SystemIOMachineEvents.renameFile,
data: {
requestedFileNameWithExtension:
fileNameForcedWithOriginalExt,