Skip to content

Commit

Permalink
fix: no add count if mode is i, c or o
Browse files Browse the repository at this point in the history
f
  • Loading branch information
Wansmer committed Sep 14, 2024
1 parent cc89712 commit aaabc02
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lua/langmapper/auto.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ local function automapping(scope, bufnr)
if not (is_same or has_map(lhs, mode, mappings)) then
local rhs = function()
local repl = vim.api.nvim_replace_termcodes(map.lhs, true, true, true)
vim.api.nvim_feedkeys((vim.v.count == 0 and '' or vim.v.count) .. repl, 'm', true)
vim.api.nvim_feedkeys(u.feed_with_count(repl), 'm', true)
end

-- No need original opts because uses `nvim_feedkeys()`
Expand Down
7 changes: 2 additions & 5 deletions lua/langmapper/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ function M._map_translated_ctrls()
if not from:find(tr_char, 1, true) then
local term_keycodes = vim.api.nvim_replace_termcodes(keycode, true, true, true)
keymap(modes, tr_keycode, function()
local count = vim.v.count == 0 and '' or vim.v.count
vim.api.nvim_feedkeys(count .. term_keycodes, 'm', true)
vim.api.nvim_feedkeys(M.feed_with_count(term_keycodes), 'm', true)
end, { desc = desc })
end
end
Expand Down Expand Up @@ -226,9 +225,7 @@ end

local function feed_nmap(keys)
keys = vim.api.nvim_replace_termcodes(keys, true, true, true)
-- Mode always should be noremap to avoid recursion
local count = vim.v.count > 0 and vim.v.count or ''
vim.api.nvim_feedkeys(count .. keys, 'n', true)
vim.api.nvim_feedkeys(M.feed_with_count(keys), 'n', true)
end

local function collect_variant_commands(from, to)
Expand Down

0 comments on commit aaabc02

Please sign in to comment.