From 6c0fdb2a7932afd502da4a0bc6b9ecbf19224bc2 Mon Sep 17 00:00:00 2001 From: Shawon Date: Tue, 7 Jan 2025 11:42:01 +0600 Subject: [PATCH] fix: Fixed a bug causing incorrect `scope_hl` in checked & unchecked checkboxes Ref: #177 --- lua/markview/renderers/markdown.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lua/markview/renderers/markdown.lua b/lua/markview/renderers/markdown.lua index 2565ef1..8d8d767 100644 --- a/lua/markview/renderers/markdown.lua +++ b/lua/markview/renderers/markdown.lua @@ -1637,7 +1637,7 @@ markdown.list_item = function (buffer, item) class = "inline_checkbox", text = item.checkbox, - range = {} + range = nil } }; @@ -1652,12 +1652,13 @@ markdown.list_item = function (buffer, item) end if state == "x" or state == "X" then - return utils.match(checkboxes, "checked", { eval_args = chk_args }); + return spec.get({ "checked" }, { source = checkboxes, eval_args = chk_args }); elseif state == " " then - return utils.match(checkboxes, "unchecked", { eval_args = chk_args }); + return spec.get({ "unchecked" }, { source = checkboxes, eval_args = chk_args }); end - return utils.match(checkboxes, state, { eval_args = chk_args }); + local _state = utils.escape_string(state) or ""; + return utils.match(checkboxes, "^" .. _state .. "$", { default = false, ignore_keys = { "checked", "unchecked", "enable" }, eval_args = chk_args }); end local checkbox = get_state(item.checkbox); @@ -2887,7 +2888,7 @@ markdown.__list_item = function (buffer, item) class = "inline_checkbox", text = item.checkbox, - range = {} + range = nil } }; @@ -2902,9 +2903,9 @@ markdown.__list_item = function (buffer, item) end if state == "x" or state == "X" then - return utils.match(checkboxes, "checked", { eval_args = chk_args }); + return spec.get({ "checked" }, { source = checkboxes, eval_args = chk_args }); elseif state == " " then - return utils.match(checkboxes, "unchecked", { eval_args = chk_args }); + return spec.get({ "unchecked" }, { source = checkboxes, eval_args = chk_args }); end return utils.match(checkboxes, state, { eval_args = chk_args });