From 90f60f9515010d8ee671c60ded88339bcf9b8445 Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Thu, 14 Mar 2024 11:10:18 -0400 Subject: [PATCH] fix: do not try to index empty location --- lua/sg/lsp/init.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lua/sg/lsp/init.lua b/lua/sg/lsp/init.lua index c2d8058e..3b0be0f1 100644 --- a/lua/sg/lsp/init.lua +++ b/lua/sg/lsp/init.lua @@ -63,7 +63,19 @@ M.get_client_id = function() -- have an error when we try to navigate synchronously to the location -- via the normal way LSPs navigate ["textDocument/definition"] = function(_, result, ctx, config_) + -- No location returned, so just quit + if not result then + return + end + if vim.tbl_islist(result) then + -- Don't do anything we have empty results, that's weird + for _, res in ipairs(result) do + if not res then + return + end + end + -- Wait for all to complete local count = 0 for _, res in ipairs(result) do