Skip to content

Commit c9262a9

Browse files
committed
text: update comments
1 parent bd94e23 commit c9262a9

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

lua/hlchunk/utils/chunkHelper.lua

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ end
9393
local function virt_text_char_width(char, shiftwidth)
9494
local b1 = char:byte(1)
9595
if b1 == 0x00 then
96-
-- NULL is a terminator when used in virtual texts
96+
-- NULL is treated as a terminator when used in virtual text
9797
return 0
9898
elseif b1 == 0x09 then
9999
return shiftwidth
100100
elseif b1 <= 0x1F or b1 == 0x7F then
101-
-- control chars other than NULL and TAB are two cells wide
101+
-- ASCII control chars other than NULL and TAB are two cells wide
102102
return 2
103103
elseif b1 <= 0x7F then
104104
-- other ASCII chars are single cell wide
@@ -201,7 +201,7 @@ function chunkHelper.rangeFromTo(i, j, step)
201201
return t
202202
end
203203

204-
---@param char_list table<integer, string>
204+
---@param char_list string[]
205205
---@param leftcol integer
206206
---@param shiftwidth integer
207207
---@return integer[]
@@ -241,7 +241,7 @@ function chunkHelper.repeatToWidth(str, width, shiftwidth)
241241
local i = 1
242242
while i <= #chars do
243243
local char_width = virt_text_char_width(chars[i], shiftwidth)
244-
---assumed to be an out-of-bounds char (like in nerd fonts) followed by a whitespace if true
244+
---if true, the char is assumed to be an out-of-bounds char (like in nerd fonts), followed by a whitespace
245245
local likely_oob_char =
246246
-- single-cell
247247
char_width == 1
@@ -305,15 +305,15 @@ function chunkHelper.checkCellsBlank(line, start_col, end_col, shiftwidth)
305305
elseif char == "\t" then
306306
next_col = current_col + shiftwidth
307307
elseif b1 <= 0x1F or char == "\127" then
308-
-- despite nvim_strwidth returning 0 or 1, control chars are 2 cells wide
308+
-- despite nvim_strwidth returning 0 or 1, ASCII control chars are 2 cells wide
309309
next_col = current_col + 2
310310
elseif b1 <= 0x7F then
311311
-- other ASCII chars are single cell wide
312312
next_col = current_col + 1
313313
else
314314
local char_width = vim.api.nvim_strwidth(char)
315315
if char_width == 1 and chars[current_char + 1] == " " then
316-
-- the char is assumed to be an out-of-bounds char (like in nerd fonts)
316+
-- the char is assumed to be an out-of-bounds char (like in nerd fonts),
317317
-- followed by a whitespace
318318
next_col = current_col + 2
319319
-- skip the whitespace part of out-of-bounds char + " "
@@ -327,9 +327,8 @@ function chunkHelper.checkCellsBlank(line, start_col, end_col, shiftwidth)
327327
-- (e.g. "%s" matches to "\v" but it will be printed as ^K)
328328
if
329329
(current_col >= start_col or next_col - 1 >= start_col)
330-
-- Singles
331-
--
332330
-- Indent characters
331+
--
333332
-- Unicode Scripts Z*
334333
-- 0020 - SPACE
335334
and char ~= " "
@@ -401,7 +400,7 @@ function chunkHelper.virtTextStrWidth(str, shiftwidth, stop_on_null)
401400
local current_width = 0
402401
for _, char in ipairs(chunkHelper.utf8Split(str)) do
403402
if stop_on_null and char == "\0" then
404-
-- NULL is a terminator when used in virtual texts
403+
-- NULL is treated as a terminator when used in virtual text
405404
return current_width
406405
end
407406
current_width = current_width + virt_text_char_width(char, shiftwidth)

0 commit comments

Comments
 (0)