From 150340f1a272d3c219abd14bd041f36a752389d0 Mon Sep 17 00:00:00 2001 From: Marco <95558991+marqmitk@users.noreply.github.com> Date: Fri, 23 Feb 2024 08:37:39 +0100 Subject: [PATCH] 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 --- plugin/codesnap.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugin/codesnap.lua b/plugin/codesnap.lua index c0f5c4a..5f81fe5 100644 --- a/plugin/codesnap.lua +++ b/plugin/codesnap.lua @@ -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