From 633e83e75f84088c6c5c6af5e84c0d38218fa3cf Mon Sep 17 00:00:00 2001 From: aarondill Date: Sun, 30 Apr 2023 09:29:17 -0500 Subject: [PATCH] fix: seemingly redundant checks, these can actually fix errors at times These checks seem redundant, but in my use, adding them actually removes a few errors if the function is called repeatedly. This should *probably* be moved to a function, but I can't think of a name for it, so for now, I will just leave it here. --- lua/tabnine/completion.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lua/tabnine/completion.lua b/lua/tabnine/completion.lua index 932d6bb..2ab0393 100644 --- a/lua/tabnine/completion.lua +++ b/lua/tabnine/completion.lua @@ -13,10 +13,11 @@ local function valid_response(response) end function M.accept() - M.clear() - if not state.rendered_completion then + if not state.completions_cache or not state.rendered_completion then return end + + M.clear() local lines = utils.str_to_lines(state.rendered_completion) if utils.starts_with(state.rendered_completion, "\n") then @@ -33,6 +34,10 @@ function M.accept() end function M.clear() + if not state.completions_cache or not state.rendered_completion then + return + end + if state.cancel_completion then state.cancel_completion() end