From 26dac2fcadb6e622790ab08e36d0dba3d3765398 Mon Sep 17 00:00:00 2001 From: Riley Bruins Date: Wed, 13 Mar 2024 07:34:38 -0700 Subject: [PATCH] fix: use larger ft icon when coloring applied (#1172) * fix: use larger ft icon when coloring applied * fix: pass filetype tests * fix: pass another test --- lua/lualine/components/filetype.lua | 8 +++++++- tests/spec/component_spec.lua | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lua/lualine/components/filetype.lua b/lua/lualine/components/filetype.lua index 673379dd2..748359fe0 100644 --- a/lua/lualine/components/filetype.lua +++ b/lua/lualine/components/filetype.lua @@ -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 @@ -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 @@ -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 diff --git a/tests/spec/component_spec.lua b/tests/spec/component_spec.lua index 42dd2bcb2..7be377bd9 100644 --- a/tests/spec/component_spec.lua +++ b/tests/spec/component_spec.lua @@ -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( @@ -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() @@ -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()