Skip to content

Commit 97cb8e9

Browse files
committed
Apply icon/color for files with more than one extension
1 parent 9672eac commit 97cb8e9

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1212
- Icon and color for symlinks and junctions are now shown, along with the target path.
1313
- [**#PR23**](https://github.com/devblackops/Terminal-Icons/pull/23) Add icons/colors for common folders `.aws`, `.Azure`, `.kube`, and `.docker` (via [@cdhunt](https://github.com/cdhunt))
1414

15+
### Fixed
16+
17+
- Colors/icons for files with more than one extension now have the theme applied.
18+
1519
## [0.2.2] 2020-01-10
1620

1721
### Added

Terminal-Icons/Private/Resolve-Icon.ps1

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,16 @@ function Resolve-Icon {
4343
if (-not $iconName) {
4444
if ($FileInfo.PSIsContainer) {
4545
$iconName = $icons.Types.$type[$FileInfo.Name]
46-
} else {
46+
} elseif ($icons.Types.$type.ContainsKey($FileInfo.Extension)) {
4747
$iconName = $icons.Types.$type[$FileInfo.Extension]
48+
} else {
49+
# File probably has multiple extensions
50+
# Fallback to computing the full extension
51+
$firstDot = $FileInfo.Name.IndexOf('.')
52+
if ($firstDot) {
53+
$fullExtension = $FileInfo.Name.Substring($firstDot)
54+
$iconName = $icons.Types.$type[$fullExtension]
55+
}
4856
}
4957
if (-not $iconName) {
5058
$iconName = $icons.Types.$type['']
@@ -54,8 +62,16 @@ function Resolve-Icon {
5462
if (-not $colorSeq) {
5563
if ($FileInfo.PSIsContainer) {
5664
$colorSeq = $colors.Types.$type[$FileInfo.Name]
57-
} else {
65+
} elseif ($colors.Types.$type.ContainsKey($FileInfo.Extension)) {
5866
$colorSeq = $colors.Types.$type[$FileInfo.Extension]
67+
} else {
68+
# File probably has multiple extensions
69+
# Fallback to computing the full extension
70+
$firstDot = $FileInfo.Name.IndexOf('.')
71+
if ($firstDot) {
72+
$fullExtension = $FileInfo.Name.Substring($firstDot)
73+
$colorSeq = $colors.Types.$type[$fullExtension]
74+
}
5975
}
6076
if (-not $colorSeq) {
6177
$colorSeq = $colors.Types.$type['']

0 commit comments

Comments
 (0)