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
pull/7/head
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
1 changed files with 6 additions and 1 deletions

View File

@ -9,11 +9,16 @@ vim.api.nvim_create_user_command("CodeSnapPreviewOn", function()
codesnap.open_preview() codesnap.open_preview()
end, {}) end, {})
local validModes = {
["v"] = true,
["V"] = true,
["^V"] = true,
}
vim.api.nvim_create_autocmd({ "CursorMoved" }, { vim.api.nvim_create_autocmd({ "CursorMoved" }, {
callback = function() callback = function()
local mode = vim.api.nvim_get_mode().mode 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 return
end end