@@ -31,73 +31,101 @@ function Resolve-Icon {
3131 switch ($FileInfo.LinkType ) {
3232 # Determine symlink or junction icon and color
3333 ' Junction' {
34- $iconName = $icons.Types .($type )[' junction' ]
35- $colorSeq = $colors.Types .($type )[' junction' ]
34+ if ($icons ) {
35+ $iconName = $icons.Types .($type )[' junction' ]
36+ } else {
37+ $iconName = $null
38+ }
39+ if ($colors ) {
40+ $colorSeq = $colors.Types .($type )[' junction' ]
41+ } else {
42+ $colorSet = $script :colorReset
43+ }
3644 $displayInfo [' Target' ] = ' ' + $FileInfo.Target
3745 break
3846 }
3947 ' SymbolicLink' {
40- $iconName = $icons.Types .($type )[' symlink' ]
41- $colorSeq = $colors.Types .($type )[' symlink' ]
48+ if ($icons ) {
49+ $iconName = $icons.Types .($type )[' symlink' ]
50+ } else {
51+ $iconName = $null
52+ }
53+ if ($colors ) {
54+ $colorSeq = $colors.Types .($type )[' symlink' ]
55+ } else {
56+ $colorSet = $script :colorReset
57+ }
4258 $displayInfo [' Target' ] = ' ' + $FileInfo.Target
4359 break
4460 } default {
45- # Determine normal directory icon and color
46- $iconName = $icons.Types .$type.WellKnown [$FileInfo.Name ]
47- if (-not $iconName ) {
48- if ($FileInfo.PSIsContainer ) {
49- $iconName = $icons.Types .$type [$FileInfo.Name ]
50- } elseif ($icons.Types .$type.ContainsKey ($FileInfo.Extension )) {
51- $iconName = $icons.Types .$type [$FileInfo.Extension ]
52- } else {
53- # File probably has multiple extensions
54- # Fallback to computing the full extension
55- $firstDot = $FileInfo.Name.IndexOf (' .' )
56- if ($firstDot -ne -1 ) {
57- $fullExtension = $FileInfo.Name.Substring ($firstDot )
58- $iconName = $icons.Types .$type [$fullExtension ]
59- }
60- }
61- if (-not $iconName ) {
62- $iconName = $icons.Types .$type [' ' ]
63- }
64-
65- # Fallback if everything has gone horribly wrong
61+ if ($icons ) {
62+ # Determine normal directory icon and color
63+ $iconName = $icons.Types .$type.WellKnown [$FileInfo.Name ]
6664 if (-not $iconName ) {
6765 if ($FileInfo.PSIsContainer ) {
68- $iconName = ' nf-oct-file_directory'
66+ $iconName = $icons.Types .$type [$FileInfo.Name ]
67+ } elseif ($icons.Types .$type.ContainsKey ($FileInfo.Extension )) {
68+ $iconName = $icons.Types .$type [$FileInfo.Extension ]
6969 } else {
70- $iconName = ' nf-fa-file'
70+ # File probably has multiple extensions
71+ # Fallback to computing the full extension
72+ $firstDot = $FileInfo.Name.IndexOf (' .' )
73+ if ($firstDot -ne -1 ) {
74+ $fullExtension = $FileInfo.Name.Substring ($firstDot )
75+ $iconName = $icons.Types .$type [$fullExtension ]
76+ }
7177 }
72- }
73- }
74- $colorSeq = $colors.Types .$type.WellKnown [$FileInfo.Name ]
75- if (-not $colorSeq ) {
76- if ($FileInfo.PSIsContainer ) {
77- $colorSeq = $colors.Types .$type [$FileInfo.Name ]
78- } elseif ($colors.Types .$type.ContainsKey ($FileInfo.Extension )) {
79- $colorSeq = $colors.Types .$type [$FileInfo.Extension ]
80- } else {
81- # File probably has multiple extensions
82- # Fallback to computing the full extension
83- $firstDot = $FileInfo.Name.IndexOf (' .' )
84- if ($firstDot -ne -1 ) {
85- $fullExtension = $FileInfo.Name.Substring ($firstDot )
86- $colorSeq = $colors.Types .$type [$fullExtension ]
78+ if (-not $iconName ) {
79+ $iconName = $icons.Types .$type [' ' ]
80+ }
81+
82+ # Fallback if everything has gone horribly wrong
83+ if (-not $iconName ) {
84+ if ($FileInfo.PSIsContainer ) {
85+ $iconName = ' nf-oct-file_directory'
86+ } else {
87+ $iconName = ' nf-fa-file'
88+ }
8789 }
8890 }
91+ } else {
92+ $iconName = $null
93+ }
94+ if ($colors ) {
95+ $colorSeq = $colors.Types .$type.WellKnown [$FileInfo.Name ]
8996 if (-not $colorSeq ) {
90- $colorSeq = $colors.Types .$type [' ' ]
91- }
97+ if ($FileInfo.PSIsContainer ) {
98+ $colorSeq = $colors.Types .$type [$FileInfo.Name ]
99+ } elseif ($colors.Types .$type.ContainsKey ($FileInfo.Extension )) {
100+ $colorSeq = $colors.Types .$type [$FileInfo.Extension ]
101+ } else {
102+ # File probably has multiple extensions
103+ # Fallback to computing the full extension
104+ $firstDot = $FileInfo.Name.IndexOf (' .' )
105+ if ($firstDot -ne -1 ) {
106+ $fullExtension = $FileInfo.Name.Substring ($firstDot )
107+ $colorSeq = $colors.Types .$type [$fullExtension ]
108+ }
109+ }
110+ if (-not $colorSeq ) {
111+ $colorSeq = $colors.Types .$type [' ' ]
112+ }
92113
93- # Fallback if everything has gone horribly wrong
94- if (-not $colorSeq ) {
95- $colorSeq = $script :colorReset
114+ # Fallback if everything has gone horribly wrong
115+ if (-not $colorSeq ) {
116+ $colorSeq = $script :colorReset
117+ }
96118 }
119+ } else {
120+ $colorSeq = $script :colorReset
97121 }
98122 }
99123 }
100- $displayInfo [' Icon' ] = $glyphs [$iconName ]
124+ if ($iconName ) {
125+ $displayInfo [' Icon' ] = $glyphs [$iconName ]
126+ } else {
127+ $displayInfo [' Icon' ] = $null
128+ }
101129 $displayInfo [' Color' ] = $colorSeq
102130 $displayInfo
103131 }
0 commit comments