Skip to content

Commit

Permalink
fix: seemingly redundant checks, these can actually fix errors at times
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aarondill authored and amirbilu committed Mar 24, 2024
1 parent e34916b commit 633e83e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lua/tabnine/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 633e83e

Please sign in to comment.