Skip to content

Commit

Permalink
fix: rename resource service
Browse files Browse the repository at this point in the history
  • Loading branch information
devcatalin committed Sep 10, 2021
1 parent 060003d commit 82b6445
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/redux/services/renameResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export const renameResource = (
},
};
const newResourceText = stringify(newResourceContent);
dispatch(updateResource({resourceId, content: newResourceText}));
if (shouldUpdateRefs && resource.refs) {
resource.refs.forEach(ref => {
if (!isIncomingRef(ref.type) || !ref.targetResourceId) {
Expand All @@ -35,7 +34,7 @@ export const renameResource = (
}
let newDependentResourceText = '';
dependentResource.text.split('\n').forEach((line, lineIndex) => {
const refAtCurrentLine = dependentResource.refs?.find(depRef => depRef.position?.line === lineIndex);
const refAtCurrentLine = dependentResource.refs?.find(depRef => depRef.position?.line === lineIndex + 1);
if (!refAtCurrentLine) {
newDependentResourceText += `${line}\n`;
return;
Expand All @@ -45,4 +44,5 @@ export const renameResource = (
dispatch(updateResource({resourceId: dependentResource.id, content: newDependentResourceText}));
});
}
dispatch(updateResource({resourceId, content: newResourceText}));
};

0 comments on commit 82b6445

Please sign in to comment.