Skip to content

Commit

Permalink
feat: defer sqlite insert to avoid highligth blink (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
gbprod committed May 15, 2024
1 parent 7c5cbf0 commit 0dc8e0f
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 @@ -37,18 +37,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 0dc8e0f

Please sign in to comment.