fix(multicursor): Visual-mode mapping loses its commands #41741

Problem:
A Visual-mode mapping that leaves Visual mode ("xmap I Q0i") does not
replay its motions/edits at the extra cursors, though an insert session
it starts does.

atom_map_start() skips while Visual is active, so the mapping has no
`composite`, and atom_capturable() then rejects its commands.

Solution:
Open the `composite` for Visual-mode mappings too.

Bonus: the mapping atom is now reported as:

    before: type=visual,  keys="viwcFOO<Esc>"
    after:  type=mapping, keys="viwc<Esc>iFOO<Esc>", lhs=",c"
This commit is contained in:
Justin M. Keyes
2026-09-06 14:50:48 -04:00
committed by GitHub
parent 5f1f5a8c2a
commit 6cbde6a95f
2 changed files with 15 additions and 2 deletions

View File

@@ -514,6 +514,20 @@ describe('multicursor', function()
end)
end)
describe('composite/mapping', function()
it('Visual-mode mapping that creates cursors (Q) #41694', function()
command('xmap I Q0i')
cursors({ 'test', 'nvim', '', 'test', 'nvim' }, '')
feed('gg$Qjjj')
atoms_start()
feed('VjI')
feed('bad<Esc>')
eq({ 'badtest', 'nvim', '', 'badtest', 'badnvim' }, get_lines())
-- "Q" is excluded: it is cursor-management, not part of the edit.
eq({ '01i\27ibad\27' }, atoms_tail(1))
end)
end)
describe('. (dot-repeat)', function()
it('repeats operators, pre-cursor edits, inserts and changes at all cursors', function()
-- Operator.