aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkianonymus <anonymus.aki@gmail.com>2022-09-03 18:07:07 +0530
committerAkianonymus <anonymus.aki@gmail.com>2022-09-03 18:07:07 +0530
commitf53bde671198b99e84ca4f9783a50f5c4b07bd68 (patch)
tree8213b58e69ad9a255e73fa7b1c9e2a2eda046d98
parentREADME: Update doc link (diff)
colorizer: Fix an edgecase when colorizer is enabled for buftype but disabled for filetype
it should remain disabled if any
-rw-r--r--lua/colorizer.lua8
1 files changed, 7 insertions, 1 deletions
diff --git a/lua/colorizer.lua b/lua/colorizer.lua
index 87acad3..13d0b43 100644
--- a/lua/colorizer.lua
+++ b/lua/colorizer.lua
@@ -301,7 +301,14 @@ local function setup(config)
local function COLORIZER_SETUP_HOOK(typ)
local filetype = vim.bo.filetype
local buftype = vim.bo.buftype
+ local buf = current_buf()
if SETUP_SETTINGS.exclusions.file[filetype] or SETUP_SETTINGS.exclusions.buf[buftype] then
+ -- when a filetype is disabled but buftype is enabled, it can Attach in
+ -- some cases, so manually detach
+ if BUFFER_OPTIONS[buf] then
+ detach_from_buffer(buf)
+ end
+ BUFFER_INIT[buf] = nil
return
end
@@ -324,7 +331,6 @@ local function setup(config)
-- this should ideally be triggered one time per buffer
-- but BufWinEnter also triggers for split formation
-- but we don't want that so add a check using local buffer variable
- local buf = current_buf()
if not BUFFER_INIT[buf] then
attach_to_buffer(buf, options, typ)
end