diff --git a/lua/lspsaga/highlight.lua b/lua/lspsaga/highlight.lua index d087cb0fd..a5015a7e4 100644 --- a/lua/lspsaga/highlight.lua +++ b/lua/lspsaga/highlight.lua @@ -4,6 +4,7 @@ local kind = require('lspsaga.lspkind').kind local function hi_define() return { -- general + SagaPrefix = { link = 'Prefix' }, SagaTitle = { link = 'Title' }, SagaBorder = { link = 'FloatBorder' }, SagaNormal = { link = 'NormalFloat' }, diff --git a/lua/lspsaga/symbol/winbar.lua b/lua/lspsaga/symbol/winbar.lua index 17638534e..459d1d474 100644 --- a/lua/lspsaga/symbol/winbar.lua +++ b/lua/lspsaga/symbol/winbar.lua @@ -21,9 +21,15 @@ local function path_in_bar(buf) local bar = bar_prefix() local items = {} + + local winbar_prefix = type(ui.winbar_prefix) == 'string' + and #ui.winbar_prefix > 0 + and '%#Prefix#' .. ui.winbar_prefix + or '' + local folder if ui.foldericon then - folder = ui.winbar_prefix .. get_kind_icon(302)[2] + folder = get_kind_icon(302)[2] end for item in util.path_itera(buf) do @@ -34,7 +40,7 @@ local function path_in_bar(buf) and '%#' .. (hl or 'SagaFileIcon') .. '#' .. (icon and icon .. ' ' or '') .. '%*' .. bar.prefix .. 'FileName#' .. item or bar.prefix .. 'Folder#' - .. (folder and folder or ui.winbar_prefix) + .. (folder and folder or '') .. '%*' .. bar.prefix .. 'FolderName#' @@ -47,7 +53,7 @@ local function path_in_bar(buf) end end - local barstr = '' + local barstr = winbar_prefix .. '' for i = #items, 1, -1 do barstr = barstr .. items[i] .. (i > 1 and bar.sep or '') end diff --git a/test/winbar_spec.lua b/test/winbar_spec.lua new file mode 100644 index 000000000..d40b52f25 --- /dev/null +++ b/test/winbar_spec.lua @@ -0,0 +1,28 @@ +require('lspsaga').setup({}) +local api = vim.api + +describe('winbar', function() + before_each(function() + local buf = api.nvim_create_buf(false, true) + api.nvim_set_current_buf(buf) + api.nvim_command('vsplit') + api.nvim_set_current_win(api.nvim_get_current_win()) + end) + + it('should handle width limitation in winbar', function() + -- Inicialize o winbar + require('lspsaga.symbol.winbar').init_winbar(api.nvim_get_current_buf()) + + -- Simula uma situação onde há muitos itens na winbar + -- (Adapte conforme necessário para criar uma lista longa de símbolos) + api.nvim_set_option_value('winbar', string.rep('Item|', 50), { + scope = 'local', + win = api.nvim_get_current_win(), + }) + + -- Verifique se o winbar lida com a largura da janela corretamente + local winbar_value = + api.nvim_get_option_value('winbar', { scope = 'local', win = api.nvim_get_current_win() }) + assert(winbar_value:match('...'), 'Winbar does not handle width limitation correctly') + end) +end)