Skip to content

Commit

Permalink
feat: defer sqlite insert to avoid highligth blink
Browse files Browse the repository at this point in the history
  • Loading branch information
gbprod committed Mar 9, 2023
1 parent c4c794a commit 81ae56f
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions lua/yanky/storage/sqlite.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,20 @@ function sqlite.setup()
end

function sqlite.push(item)
sqlite.db:with_open(function()
sqlite.db:eval(
"INSERT INTO history (filetype, regcontents, regtype) VALUES (:filetype, :regcontents, :regtype)",
item
)
vim.schedule(function()
sqlite.db:with_open(function()
sqlite.db:eval(
"INSERT INTO history (filetype, regcontents, regtype) VALUES (:filetype, :regcontents, :regtype)",
item
)

sqlite.db:eval(
string.format(
"DELETE FROM history WHERE id NOT IN (SELECT id FROM history ORDER BY id DESC LIMIT %s)",
sqlite.config.history_length
sqlite.db:eval(
string.format(
"DELETE FROM history WHERE id NOT IN (SELECT id FROM history ORDER BY id DESC LIMIT %s)",
sqlite.config.history_length
)
)
)
end)
end)
end

Expand Down

0 comments on commit 81ae56f

Please sign in to comment.