9797local function virt_text_char_width (char , shiftwidth )
9898 local b1 = char :byte (1 )
9999 if b1 == 0x00 then
100- -- NULL is a terminator when used in virtual texts
100+ -- NULL is treated as a terminator when used in virtual text
101101 return 0
102102 elseif b1 == 0x09 then
103103 return shiftwidth
104104 elseif b1 <= 0x1F or b1 == 0x7F then
105- -- control chars other than NULL and TAB are two cells wide
105+ -- ASCII control chars other than NULL and TAB are two cells wide
106106 return 2
107107 elseif b1 <= 0x7F then
108108 -- other ASCII chars are single cell wide
@@ -205,7 +205,7 @@ function chunkHelper.rangeFromTo(i, j, step)
205205 return t
206206end
207207
208- --- @param char_list table<integer , string>
208+ --- @param char_list string[]
209209--- @param leftcol integer
210210--- @param shiftwidth integer
211211--- @return integer[]
@@ -245,7 +245,7 @@ function chunkHelper.repeatToWidth(str, width, shiftwidth)
245245 local i = 1
246246 while i <= # chars do
247247 local char_width = virt_text_char_width (chars [i ], shiftwidth )
248- --- assumed to be an out-of-bounds char (like in nerd fonts) followed by a whitespace if true
248+ --- if true, the char is assumed to be an out-of-bounds char (like in nerd fonts), followed by a whitespace
249249 local likely_oob_char =
250250 -- single-cell
251251 char_width == 1
@@ -309,15 +309,15 @@ function chunkHelper.checkCellsBlank(line, start_col, end_col, shiftwidth)
309309 elseif char == " \t " then
310310 next_col = current_col + shiftwidth
311311 elseif b1 <= 0x1F or char == " \127 " then
312- -- despite nvim_strwidth returning 0 or 1, control chars are 2 cells wide
312+ -- despite nvim_strwidth returning 0 or 1, ASCII control chars are 2 cells wide
313313 next_col = current_col + 2
314314 elseif b1 <= 0x7F then
315315 -- other ASCII chars are single cell wide
316316 next_col = current_col + 1
317317 else
318318 local char_width = vim .api .nvim_strwidth (char )
319319 if char_width == 1 and chars [current_char + 1 ] == " " then
320- -- the char is assumed to be an out-of-bounds char (like in nerd fonts)
320+ -- the char is assumed to be an out-of-bounds char (like in nerd fonts),
321321 -- followed by a whitespace
322322 next_col = current_col + 2
323323 -- skip the whitespace part of out-of-bounds char + " "
@@ -331,9 +331,8 @@ function chunkHelper.checkCellsBlank(line, start_col, end_col, shiftwidth)
331331 -- (e.g. "%s" matches to "\v" but it will be printed as ^K)
332332 if
333333 (current_col >= start_col or next_col - 1 >= start_col )
334- -- Singles
335- --
336334 -- Indent characters
335+ --
337336 -- Unicode Scripts Z*
338337 -- 0020 - SPACE
339338 and char ~= " "
@@ -344,6 +343,7 @@ function chunkHelper.checkCellsBlank(line, start_col, end_col, shiftwidth)
344343 and char ~= " "
345344 --
346345 -- Non indent characters
346+ --
347347 -- Unicode Scripts Z*
348348 -- 00A0 - NO-BREAK SPACE
349349 and char ~= " "
@@ -376,6 +376,7 @@ function chunkHelper.checkCellsBlank(line, start_col, end_col, shiftwidth)
376376 ]]
377377 --
378378 -- Others
379+ --
379380 -- 2800 - BRAILLE PATTERN BLANK
380381 and char ~= " ⠀"
381382 --[[
@@ -405,7 +406,7 @@ function chunkHelper.virtTextStrWidth(str, shiftwidth, stop_on_null)
405406 local current_width = 0
406407 for _ , char in ipairs (chunkHelper .utf8Split (str )) do
407408 if stop_on_null and char == " \0 " then
408- -- NULL is a terminator when used in virtual texts
409+ -- NULL is treated as a terminator when used in virtual text
409410 return current_width
410411 end
411412 current_width = current_width + virt_text_char_width (char , shiftwidth )
0 commit comments