Fixed not updating (#6)

Sometimes the preview didn't update for me, because the wrong mode was getting detected, providing more modes should fix it
This commit is contained in:
Marco 2024-02-23 08:37:39 +01:00 committed by GitHub
parent 28749ae8e9
commit 150340f1a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,11 +9,16 @@ vim.api.nvim_create_user_command("CodeSnapPreviewOn", function()
codesnap.open_preview()
end, {})
local validModes = {
["v"] = true,
["V"] = true,
["^V"] = true,
}
vim.api.nvim_create_autocmd({ "CursorMoved" }, {
callback = function()
local mode = vim.api.nvim_get_mode().mode
if mode ~= "v" or not codesnap.preview_switch then
if not validModes[mode] or not codesnap.preview_switch then
return
end