fix(dial): Fix dial commands in Visual line+block (#2933)

This commit is contained in:
Gethin Davies 2024-05-14 21:36:31 +01:00 committed by GitHub
parent 3585d61c93
commit 1df3c5d70b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,7 +5,9 @@ M.dials_by_ft = {}
---@param increment boolean
---@param g? boolean
function M.dial(increment, g)
local is_visual = vim.fn.mode(true):sub(1, 1) == "v"
local mode = vim.fn.mode(true)
-- Use visual commands for VISUAL 'v', VISUAL LINE 'V' and VISUAL BLOCK '\22'
local is_visual = mode == "v" or mode == "V" or mode == "\22"
local func = (increment and "inc" or "dec") .. (g and "_g" or "_") .. (is_visual and "visual" or "normal")
local group = M.dials_by_ft[vim.bo.filetype] or "default"
return require("dial.map")[func](group)