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