( hatTokenMap: IndividualHatMap, decorations: Decorations )
| 15 | } |
| 16 | |
| 17 | export function addDecorationsToEditors( |
| 18 | hatTokenMap: IndividualHatMap, |
| 19 | decorations: Decorations |
| 20 | ) { |
| 21 | hatTokenMap.clear(); |
| 22 | |
| 23 | var editors: vscode.TextEditor[]; |
| 24 | |
| 25 | if (vscode.window.activeTextEditor == null) { |
| 26 | editors = vscode.window.visibleTextEditors; |
| 27 | } else { |
| 28 | editors = vscode.window.visibleTextEditors.filter( |
| 29 | (editor) => editor !== vscode.window.activeTextEditor |
| 30 | ); |
| 31 | editors.unshift(vscode.window.activeTextEditor); |
| 32 | } |
| 33 | |
| 34 | const tokens = concat( |
| 35 | [], |
| 36 | ...editors.map((editor) => { |
| 37 | const displayLineMap = getDisplayLineMap(editor); |
| 38 | |
| 39 | const tokens: Token[] = flatten( |
| 40 | editor.visibleRanges.map((range) => |
| 41 | getTokensInRange(editor, range).map((partialToken) => ({ |
| 42 | ...partialToken, |
| 43 | displayLine: displayLineMap.get(partialToken.range.start.line)!, |
| 44 | editor, |
| 45 | expansionBehavior: { |
| 46 | start: { type: "regex", regex: TOKEN_MATCHER }, |
| 47 | end: { type: "regex", regex: TOKEN_MATCHER }, |
| 48 | }, |
| 49 | })) |
| 50 | ) |
| 51 | ); |
| 52 | |
| 53 | tokens.sort( |
| 54 | getTokenComparator( |
| 55 | displayLineMap.get(editor.selection.active.line)!, |
| 56 | editor.selection.active.character |
| 57 | ) |
| 58 | ); |
| 59 | |
| 60 | return tokens; |
| 61 | }) |
| 62 | ); |
| 63 | |
| 64 | const characterTokens: { |
| 65 | [key: string]: Map<Token, CharacterTokenInfo>; |
| 66 | } = {}; |
| 67 | |
| 68 | tokens.forEach((token, tokenIdx) => { |
| 69 | [...token.text].forEach((character, characterIdx) => { |
| 70 | var characterTokenMap: Map<Token, CharacterTokenInfo>; |
| 71 | |
| 72 | if (character in characterTokens) { |
| 73 | characterTokenMap = characterTokens[character]; |
| 74 | } else { |
no test coverage detected