mirror of
https://github.com/neovim/neovim.git
synced 2026-06-15 16:23:48 +00:00
fix(pos): get_lines() never correctly fallbacks to empty string
Problem: `nvim_buf_get_lines` will always returns a table, so the `or` operator will never be used, letting `lines[row]` may be `nil` Solution: Fix it.
This commit is contained in:
@@ -70,7 +70,7 @@ function M.get_lines(buf, rows)
|
||||
local function buf_lines()
|
||||
local row_line = {} --- @type table<integer,string>
|
||||
for _, row in ipairs(rows) do
|
||||
row_line[row] = (api.nvim_buf_get_lines(buf, row, row + 1, false) or { '' })[1]
|
||||
row_line[row] = api.nvim_buf_get_lines(buf, row, row + 1, false)[1] or ''
|
||||
end
|
||||
return row_line
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user