Skip to content

Commit 06337f6

Browse files
fix: handle leading spaces in checkbox bullet
## Details Issue: #158 This is similar to the already solved issue of leading space in the first list item of "overly" indented lists. I say overly because technically the markdown syntax is specific to 2 spaces per indentation level for lists. To resolve this rather than concealing the entire list marker range only conceal the range after any leading white space. I'm not entirely sure why concealing the full range causes some text to be cut off for me. I'm guessing there is some strangeness in what it means to conceal empty space but that is a guess on my part. Adjusting the range seems to work well in either case.
1 parent c46468f commit 06337f6

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

lua/render-markdown/handler/markdown.lua

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,15 @@ function Handler:list_marker(info)
116116
end
117117
return false
118118
end
119+
120+
-- List markers from tree-sitter should have leading spaces removed, however there are known
121+
-- edge cases in the parser: https://github.com/tree-sitter-grammars/tree-sitter-markdown/issues/127
122+
-- As a result we account for leading spaces here, can remove if this gets fixed upstream
123+
local leading_spaces = str.leading_spaces(info.text)
124+
119125
if sibling_checkbox() then
120126
-- Hide the list marker for checkboxes rather than replacing with a bullet point
121-
self.marks:add(true, info.start_row, info.start_col, {
127+
self.marks:add(true, info.start_row, info.start_col + leading_spaces, {
122128
end_row = info.end_row,
123129
end_col = info.end_col,
124130
conceal = '',
@@ -133,10 +139,6 @@ function Handler:list_marker(info)
133139
if icon == nil then
134140
return
135141
end
136-
-- List markers from tree-sitter should have leading spaces removed, however there are known
137-
-- edge cases in the parser: https://github.com/tree-sitter-grammars/tree-sitter-markdown/issues/127
138-
-- As a result we handle leading spaces here, can remove if this gets fixed upstream
139-
local leading_spaces = str.leading_spaces(info.text)
140142
self.marks:add(true, info.start_row, info.start_col, {
141143
end_row = info.end_row,
142144
end_col = info.end_col,

lua/render-markdown/health.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ local M = {}
55

66
---@private
77
---@type string
8-
M.version = '6.3.5'
8+
M.version = '6.3.6'
99

1010
function M.check()
1111
vim.health.start('render-markdown.nvim [version]')

0 commit comments

Comments
 (0)