Skip to main content

overtypes_in_select

Function overtypes_in_select 

Source
pub fn overtypes_in_select(chord: &KeyChord) -> bool
Expand description

Does chord overtype a Select-mode selection when nothing binds it?

The ONE definition of the rule. Select’s overtype fallback calls it, and so does the motion mirror when deciding what may be bound in Select. Two copies of “what counts as typing” would drift apart, and a keymap that disagrees with its dispatcher is exactly the bug VM.4 fixed.

Vim’s rule (visual.txt, Select mode): “Printable characters, and cause the selection to be deleted, and Vim enters Insert mode.”

  • A bare Char overtypes: any character, space and non-ASCII included.
  • <CR> is Special(Enter).
  • <NL> has no key of its own; a terminal sends it as Ctrl-J.

Ctrl, Alt or Super otherwise make it a chord, not typing. Shift doesn’t count: Select strips it before the lookup, and a shifted letter arrives as its uppercase Char anyway.

§Examples

use lattice_keymap::overtypes_in_select;
use lattice_protocol::KeyChord;
use lattice_protocol::chord::SpecialKey;

assert!(overtypes_in_select(&KeyChord::char('x')));
assert!(overtypes_in_select(&KeyChord::special(SpecialKey::Enter)));
assert!(overtypes_in_select(&KeyChord::ctrl('j'))); // <NL>
assert!(!overtypes_in_select(&KeyChord::ctrl('d')));
assert!(!overtypes_in_select(&KeyChord::special(SpecialKey::Down)));