(isClear = false)
| 18 | constructor(public muya: Muya) {} |
| 19 | |
| 20 | private _updateMatches(isClear = false) { |
| 21 | const { matches, index } = this; |
| 22 | let i; |
| 23 | const len = matches.length; |
| 24 | const matchesMap = new Map<Content, IHighlight[]>(); |
| 25 | |
| 26 | for (i = 0; i < len; i++) { |
| 27 | const { block, start, end } = matches[i]; |
| 28 | const active = i === index; |
| 29 | const highlight: IHighlight = { start, end, active }; |
| 30 | const highlights = matchesMap.get(block); |
| 31 | |
| 32 | if (matchesMap.has(block) && Array.isArray(highlights)) { |
| 33 | highlights.push(highlight); |
| 34 | matchesMap.set(block, highlights); |
| 35 | } |
| 36 | else { |
| 37 | matchesMap.set(block, [highlight]); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | for (const [block, highlights] of matchesMap.entries()) { |
| 42 | const isActive = highlights.some(h => h.active); |
| 43 | |
| 44 | block.update(undefined, isClear ? [] : highlights); |
| 45 | |
| 46 | if (block.parent?.active && !isActive) |
| 47 | block.blurHandler(); |
| 48 | |
| 49 | if (isActive && !isClear) |
| 50 | block.focusHandler(); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | private _innerReplace(matches: IMatch[], value: string) { |
| 55 | if (!matches.length) |
no test coverage detected