fix: multicursor when opened with --preview (#701)

This commit is contained in:
jake-stewart 2026-01-01 04:50:39 +08:00 committed by GitHub
parent 963c8d2c55
commit 78ed0cf7d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -543,6 +543,8 @@ M.open_preview = function(opts, callback)
end
util.get_edit_path(bufnr, entry, function(normalized_url)
local mc = package.loaded["multicursor-nvim"]
local has_multicursors = mc and mc.hasCursors()
local is_visual_mode = util.is_visual_mode()
if preview_win then
if is_visual_mode then
@ -601,7 +603,10 @@ M.open_preview = function(opts, callback)
end
vim.w.oil_entry_id = entry.id
vim.w.oil_source_win = prev_win
if is_visual_mode then
if has_multicursors then
hack_set_win(prev_win)
mc.restoreCursors()
elseif is_visual_mode then
hack_set_win(prev_win)
-- Restore the visual selection
vim.cmd.normal({ args = { "gv" }, bang = true })