Skip to content

Commit

Permalink
Merge pull request #10 from lexiccn/main
Browse files Browse the repository at this point in the history
Fix error where name of node is also the name of a parent (but not root) node
  • Loading branch information
LlmDl authored May 29, 2024
2 parents 1d7a017 + b402a39 commit f492a1d
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ private int getWhiteSpaceFromLine(String line) {
*/
private String shrinkCurrentPath(String currentPath, int newDepth) {
for (int i = 0; i < depth - newDepth; i++)
currentPath = currentPath.replace(currentPath.substring(currentPath.lastIndexOf(".")), "");
currentPath = currentPath.substring(0, currentPath.lastIndexOf("."));
return currentPath;
}

Expand All @@ -299,9 +299,8 @@ private String addNodeNameToCurrentPath(String currentPath, String nodeName) {
// at root
currentPath = "";
} else {
// If there is a final period, replace everything after it with nothing
currentPath = currentPath.replace(currentPath.substring(lastIndex), "");
currentPath += ".";
// If there is a final period, trim everything after it
currentPath = currentPath.substring(0, lastIndex+1);
}
return currentPath += nodeName;
}
Expand Down

0 comments on commit f492a1d

Please sign in to comment.