Rich text / foldkit-mixins-richtext

slashMove

function · packages/mixins-richtext/src/slash.ts:49

function slashMove<Message>(
  entries: ReadonlyArray<SlashEntry<Message>>,
  textBefore: string,
  index: number,
  key: string,
  modifiers: KeyboardModifiers,
): number | undefined

The index an arrow — or Home, or End — moves the highlight to among the current matches, or undefined when the key moves nothing. The rule is foldkit-primitives' RovingTabindex.move, so the menu and any other list agree on ArrowUp/ArrowDown, Home/End, wrapping, and on a modified key moving nothing; the menu adds only "over the entries the query currently matches".

It moves from what slashMenu highlights rather than from the caller's remembered index, so a query that narrowed past it is not moved from a position the user cannot see.