Skip to content
This repository was archived by the owner on Oct 13, 2021. It is now read-only.

Commit 64fc365

Browse files
committed
fix: check for nil value in completionConfirm
1 parent edfdb8c commit 64fc365

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

lua/completion.lua

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,16 @@ function M.confirmCompletion()
5555
if M.completionConfirm == true then
5656
local complete_item = api.nvim_get_vvar('completed_item')
5757
local lnum, _ = unpack(api.nvim_win_get_cursor(0))
58-
local item = complete_item.user_data.lsp.completion_item
59-
local bufnr = api.nvim_get_current_buf()
60-
if item.additionalTextEdits then
61-
local edits = vim.tbl_filter(
62-
function(x) return x.range.start.line ~= (lnum - 1) end,
63-
item.additionalTextEdits
64-
)
65-
vim.lsp.util.apply_text_edits(edits, bufnr)
58+
if complete_item.user_data.lsp ~= nil then
59+
local item = complete_item.user_data.lsp.completion_item
60+
local bufnr = api.nvim_get_current_buf()
61+
if item.additionalTextEdits then
62+
local edits = vim.tbl_filter(
63+
function(x) return x.range.start.line ~= (lnum - 1) end,
64+
item.additionalTextEdits
65+
)
66+
vim.lsp.util.apply_text_edits(edits, bufnr)
67+
end
6668
end
6769

6870
if vim.g.completion_enable_auto_paren == 1 then

0 commit comments

Comments
 (0)