Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lua/hlchunk/utils/indentHelper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,22 @@ local function get_rows_indent_by_treesitter(range)
local bufnr = range.bufnr
for i = range.start, range.finish, 1 do
local t1 = vim.api.nvim_buf_call(bufnr, function()
return ts_indent.get_indent(i + 1)
local ok, indent = pcall(ts_indent.get_indent, i + 1)
return ok and indent or nil
end)

if t1 == nil then
goto continue
end

local t2 = cFunc.get_indent(bufnr, i)
local line_len = cFunc.get_line_len(bufnr, i)
local indent = math.min(t1, t2)
if indent == 0 and line_len == 0 then
indent = get_virt_indent(bufnr, i)
end
rows_indent[i] = indent
::continue::
end

return indentHelper.ROWS_INDENT_RETCODE.OK, rows_indent
Expand Down