Skip to content

Commit

Permalink
fix: use larger ft icon when coloring applied (#1172)
Browse files Browse the repository at this point in the history
* fix: use larger ft icon when coloring applied

* fix: pass filetype tests

* fix: pass another test
  • Loading branch information
ribru17 authored Mar 13, 2024
1 parent 3c55675 commit 26dac2f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion lua/lualine/components/filetype.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ function M:apply_icon()
icon = ''
icon_highlight_group = 'DevIconDefault'
end
if icon then
icon = icon .. ' '
end
if self.options.colored then
local highlight_color = modules.utils.extract_highlight_colors(icon_highlight_group, 'fg')
if highlight_color then
Expand All @@ -57,6 +60,9 @@ function M:apply_icon()
ok = vim.fn.exists('*WebDevIconsGetFileTypeSymbol')
if ok ~= 0 then
icon = vim.fn.WebDevIconsGetFileTypeSymbol()
if icon then
icon = icon .. ' '
end
end
end

Expand All @@ -69,7 +75,7 @@ function M:apply_icon()
elseif type(self.options.icon) == 'table' and self.options.icon.align == 'right' then
self.status = self.status .. ' ' .. icon
else
self.status = icon .. ' ' .. self.status
self.status = icon .. self.status
end
end

Expand Down
6 changes: 3 additions & 3 deletions tests/spec/component_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ describe('Filetype component', function()
colored = true,
icon_only = false,
}
assert_component('filetype', opts, '%#MyCompHl_normal#*%#lualine_c_normal# lua%#lualine_c_normal#')
assert_component('filetype', opts, '%#MyCompHl_normal#* %#lualine_c_normal#lua%#lualine_c_normal#')
assert.stub(devicons.get_icon).was_called_with('test.lua')
assert.stub(utils.extract_highlight_colors).was_called_with('test_highlight_group', 'fg')
assert.stub(hl.create_component_highlight_group).was_called_with(
Expand Down Expand Up @@ -393,7 +393,7 @@ describe('Filetype component', function()
colored = false,
icon_only = true,
}
assert_component('filetype', opts, '*')
assert_component('filetype', opts, '* ')
assert.stub(devicons.get_icon).was_called_with('test.lua')
assert.stub(utils.extract_highlight_colors).was_not_called()
assert.stub(hl.create_component_highlight_group).was_not_called()
Expand Down Expand Up @@ -426,7 +426,7 @@ describe('Filetype component', function()
icon_only = false,
icon = { align = 'right' }
}
assert_component('filetype', opts, 'lua *')
assert_component('filetype', opts, 'lua * ')
assert.stub(devicons.get_icon).was_called_with('test.lua')
assert.stub(utils.extract_highlight_colors).was_not_called()
assert.stub(hl.create_component_highlight_group).was_not_called()
Expand Down

0 comments on commit 26dac2f

Please sign in to comment.