From 5beb751ef5f818753958dffe485011951f0912dc Mon Sep 17 00:00:00 2001 From: Yi Ming Date: Tue, 2 Jun 2026 15:10:05 +0800 Subject: [PATCH] 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. --- runtime/lua/vim/pos/_util.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/lua/vim/pos/_util.lua b/runtime/lua/vim/pos/_util.lua index af20b010b1..45e17386a3 100644 --- a/runtime/lua/vim/pos/_util.lua +++ b/runtime/lua/vim/pos/_util.lua @@ -70,7 +70,7 @@ function M.get_lines(buf, rows) local function buf_lines() local row_line = {} --- @type table 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