findNearestMatchIndex

Returns the index into matches of the match nearest the cursor.

Prefers the first match at or after cursorPosition, wrapping back to the first match when every match precedes the cursor, and favoring an enclosing match when the cursor sits inside one.

Return

The index of the nearest match, or -1 when matches is empty.

Parameters

matches

Matches in document order, as returned by findAll.

cursorPosition

The current cursor location.