Fix get_node_text

This commit is contained in:
MDeiml 2022-01-08 01:37:18 +01:00 committed by Stephan Seitz
parent 99d4d7e2d8
commit 46b9916492

View file

@ -21,7 +21,10 @@ function M.get_node_text(node, bufnr)
if start_row ~= end_row then
local lines = api.nvim_buf_get_lines(bufnr, start_row, end_row + 1, false)
lines[1] = string.sub(lines[1], start_col + 1)
lines[#lines] = string.sub(lines[#lines], 1, end_col)
-- end_row might be just after the last line. In this case the last line is not truncated.
if #lines == end_row - start_row then
lines[#lines] = string.sub(lines[#lines], 1, end_col)
end
return lines
else
local line = api.nvim_buf_get_lines(bufnr, start_row, start_row + 1, false)[1]