fix(multicursor): abandoned Visual selection does not move cursors #41670

Problem:
"v{motion}<Esc>" moves the primary cursor to the selection end, but the
other cursors snap back to their anchors unless follow-mode ("q=") is
on. The selection preview showed them at the selection end.

Solution:
Replay the abandoned selection at every cursor, not only in follow-mode.
An abandoned typed selection now always emits a "visual" CmdAtom.
This commit is contained in:
Justin M. Keyes
2026-09-03 15:20:30 -04:00
committed by GitHub
parent ce8a897f98
commit 5209695703
3 changed files with 24 additions and 23 deletions

View File

@@ -849,11 +849,15 @@ describe('CmdAtom', function()
feed(',D')
eq(before, #atoms())
atom('w', 'dw', ',Dw') -- The supplied motion finishes the operation
-- Same for a mapping that opens Visual mode: "<Esc>" abandons the selection and closes it.
-- Same for a mapping that opens Visual mode: ESC closes the selection (cursor stays on the
-- selection end, where it moved during the Visual sequence).
feed(',V')
eq(before + 1, #atoms())
feed('<Esc>')
eq({ type = 'mapping', lhs = k(',V<Esc>') }, pick(atom_last(), 'type', 'lhs', 'keys'))
eq(
{ type = 'visual', lhs = k(',V<Esc>'), keys = k('v<Esc>') },
pick(atom_last(), 'type', 'lhs', 'keys')
)
-- A mapping whose trailing prefix is completed by TYPED keys ("," + "w")
-- ends where its own keys stop: each `lhs` owns only what it produced.
command('set notimeout')