Skip to content

Error on winbar highlighting result #339

@kevinm6

Description

@kevinm6

Hello, thanks for the plugin.
Using it and updated to the last release with luarocks dependency and the other updates I get an error on the result highlight of the winbar.

Due to this part of the code

local hl_fg = string.format("%02X", vim.api.nvim_get_hl(0, { name = name, link = false }).fg)
if #hl_fg == 5 then
hl_fg = "0" .. hl_fg
end
hl_fg = "#" .. hl_fg
return hl_fg

when the Hex value of the highlight contains two prefixed zeros (example #00FF87) it doesn’t match to any of the if statement since you’re checking if the chars left after the format are 5, but in this case they are 4.

In the most simple way is enough to do another check and have something like this

  local hl_fg = string.format("%02X", vim.api.nvim_get_hl(0, { name = name, link = false }).fg)
  if #hl_fg == 4 then
    hl_fg = "00" .. hl_fg
  elseif #hl_fg == 5 then
    hl_fg = "0" .. hl_fg
  end
  hl_fg = "#" .. hl_fg
  return hl_fg

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions