mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-04 04:20:09 -04:00
Fix get_node_text
This commit is contained in:
parent
99d4d7e2d8
commit
46b9916492
1 changed files with 4 additions and 1 deletions
|
|
@ -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]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue