mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-19 11:50: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
|
if start_row ~= end_row then
|
||||||
local lines = api.nvim_buf_get_lines(bufnr, start_row, end_row + 1, false)
|
local lines = api.nvim_buf_get_lines(bufnr, start_row, end_row + 1, false)
|
||||||
lines[1] = string.sub(lines[1], start_col + 1)
|
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
|
return lines
|
||||||
else
|
else
|
||||||
local line = api.nvim_buf_get_lines(bufnr, start_row, start_row + 1, false)[1]
|
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