kdheepak / tabline.nvim

A "buffer and tab" tabline for neovim
MIT License
230 stars 17 forks source link

Fix boolean options that have default value `true` #39

Closed s-cerevisiae closed 2 years ago

s-cerevisiae commented 2 years ago

As of now, boolean options with a default value of true could not be properly set:

-- { options = { show_devicons = false } }
if opts.options.show_devicons then -- this is false
  M.options.show_devicons = opts.options.show_devicons
else -- goes here
  M.options.show_devicons = vim.g.tabline_show_devicons -- which is true
end

This PR fixes this by (defensively) test all boolean options against nil, no matter what its default value currently is:

-- { options = { show_devicons = false } }
if opts.options.show_devicons ~= nil then
  M.options.show_devicons = opts.options.show_devicons -- goes here, which is false
else
  M.options.show_devicons = vim.g.tabline_show_devicons
end
kdheepak commented 2 years ago

Yes, you are correct. This is the better way to do it. Thanks for making the PR.

s-cerevisiae commented 2 years ago

During this I've also found that the wrong name is being used for M.options.show_tabs_always so it actually doesn't work... (here) But this should be addressed in a different branch I guess.

kdheepak commented 2 years ago

Thanks for pointing that out! Fixed in https://github.com/kdheepak/tabline.nvim/commit/436b8778350e3b17615869fbb3fe4b206357d76d.