Skip to content

Commit

Permalink
Update tree file view description for renamed files
Browse files Browse the repository at this point in the history
Issue #702
  • Loading branch information
tsantalis committed Apr 26, 2024
1 parent 3266b78 commit 7c07871
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/main/java/gui/webdiff/DirectoryDiffView.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void renderNode(HtmlCanvas ul, DefaultMutableTreeNode node) throws IOExc
if (node.getUserObject() != null) {
TreeNodeInfo nodeInfo = (TreeNodeInfo) node.getUserObject();
if (node.isLeaf()) {
String iconPath = null;
String iconPath = null, description = nodeInfo.getName();
int iconWidth = 0, iconHeight = 0;
if(isModifiedFile(nodeInfo)) {
iconPath = "dist/icons8-file-edit.svg";
Expand All @@ -113,10 +113,21 @@ private void renderNode(HtmlCanvas ul, DefaultMutableTreeNode node) throws IOExc
iconPath = "dist/icons8-file-move.svg";
iconWidth = 15;
iconHeight = 17;
ASTDiff astDiff = comperator.getASTDiff(nodeInfo.getId());
if(astDiff != null && astDiff.getSrcPath() != null) {
String srcName = astDiff.getSrcPath();
if(astDiff.getSrcPath().contains("/")) {
srcName = srcName.substring(srcName.lastIndexOf("/") + 1, srcName.length());
}
if(!srcName.equals(nodeInfo.getName())) {
//file is renamed
description = srcName + " → " + nodeInfo.getName();
}
}
}
ul.tr()
//.td().content(nodeInfo.getName())
.td().a(href("/monaco-diff/" + nodeInfo.getId())).img(src(iconPath).width(iconWidth).height(iconHeight)).write(" " + nodeInfo.getName())._a()._td()
.td().a(href("/monaco-diff/" + nodeInfo.getId())).img(src(iconPath).width(iconWidth).height(iconHeight)).write(" " + description)._a()._td()
.td()
.div(class_("btn-toolbar justify-content-end"))
.div(class_("btn-group"))
Expand Down

0 comments on commit 7c07871

Please sign in to comment.