mirror of
https://github.com/neovim/neovim.git
synced 2024-09-17 20:58:20 -04:00
fix(treesitter): get_node_text()
newling handling consistency
- Modified `buf_range_get_text` to insert the trailing newline char.
This commit is contained in:
parent
48c2ad5d2d
commit
4531c2a04e
@ -187,6 +187,7 @@ end
|
||||
---@returns string
|
||||
local function buf_range_get_text(buf, range)
|
||||
local start_row, start_col, end_row, end_col = M._range.unpack4(range)
|
||||
local insert_nl = false
|
||||
if end_col == 0 then
|
||||
if start_row == end_row then
|
||||
start_col = -1
|
||||
@ -194,8 +195,12 @@ local function buf_range_get_text(buf, range)
|
||||
end
|
||||
end_col = -1
|
||||
end_row = end_row - 1
|
||||
insert_nl = true
|
||||
end
|
||||
local lines = api.nvim_buf_get_text(buf, start_row, start_col, end_row, end_col, {})
|
||||
if insert_nl then
|
||||
table.insert(lines, "")
|
||||
end
|
||||
return table.concat(lines, '\n')
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user