Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
Solve the problem that the icons are colored even after using the '--…
Browse files Browse the repository at this point in the history
…no-colors' option
  • Loading branch information
0x61nas committed Jun 10, 2022
1 parent f67e122 commit 7907325
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/anas/javautils/jls/output/FileInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public String getCreationTime(final boolean withColor) {
return withColor ? str.toString() : str.getNormalString();
}

public Icon getIcon(final boolean withColor) {
public Icon getIcon() {
Icon icon = Icon.getCorrectIcon(getName());

if (icon != null) return icon;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/anas/javautils/jls/output/Icon.java
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,8 @@ public String toString() {
new String(color.getForegroundSGRSequence(), StandardCharsets.UTF_8) + "m" +
icon + "\033[0m";
}

public String getNoColoredIcon() {
return icon + "";
}
}
3 changes: 2 additions & 1 deletion src/main/java/com/anas/javautils/jls/output/ListOfFiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ private String getShortFormat(
(withSize ? " %s" : "%s");

return String.format(format,
IS_NO_ICONS ? "" : fileInfo.getIcon(IS_WITH_NO_COLORS),
IS_NO_ICONS ? "" : (IS_WITH_NO_COLORS ?
fileInfo.getIcon().toString() : fileInfo.getIcon().getNoColoredIcon()),
fileInfo.getName(IS_WITH_NO_COLORS),
fileInfo.isSymlink() ? fileInfo.getSymlinkTarget(IS_WITH_NO_COLORS) : "",
withSize ? fileInfo.getSize(IS_HUMAN_READABLE, IS_WITH_NO_COLORS) : ""
Expand Down

0 comments on commit 7907325

Please sign in to comment.