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:
Yi Ming
2026-06-02 15:10:05 +08:00
parent d369979328
commit 5beb751ef5

View File

@@ -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