mirror of
https://github.com/athityakumar/colorls.git
synced 2024-09-19 05:31:23 +02:00
Fix unrecognized files count and colorization
A *file* is assigned a generic icon / glyph in `files.yaml`, so looking up `:file` in the corresponding hash always succeeds, but `:file` is also used as the fallback key if a file's extension is not recognized. First determining the color and group of a given file before falling back to the `:file` key fixes this issue.
This commit is contained in:
parent
c36ed1a78b
commit
52b8c3489d
2 changed files with 9 additions and 1 deletions
|
@ -328,9 +328,9 @@ module ColorLS
|
|||
else
|
||||
key = content.name.split('.').last.downcase.to_sym
|
||||
key = @file_aliases[key] unless @files.key? key
|
||||
key = :file if key.nil?
|
||||
color = file_color(content, key)
|
||||
group = @files.key?(key) ? :recognized_files : :unrecognized_files
|
||||
key = :file if key.nil?
|
||||
end
|
||||
|
||||
[key, color, group]
|
||||
|
|
|
@ -300,4 +300,12 @@ RSpec.describe ColorLS::Flags do
|
|||
expect { subject }.to output(/setlocale error/).to_stderr.and output.to_stdout
|
||||
end
|
||||
end
|
||||
|
||||
context 'with unrecognized files' do
|
||||
let(:args) { ['--report', FIXTURES] }
|
||||
|
||||
it 'should show a report with unrecognized files' do
|
||||
expect { subject }.to output(/Unrecognized files\s+: 3/).to_stdout
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue