| 99 | * ``` |
| 100 | */ |
| 101 | export function createDetails( |
| 102 | line: DiffResult<string>, |
| 103 | tokens: DiffResult<string>[], |
| 104 | ): DiffResult<string>[] { |
| 105 | return tokens.filter(({ type }) => type === line.type || type === "common") |
| 106 | .map((result, i, t) => { |
| 107 | const token = t[i - 1]; |
| 108 | if ( |
| 109 | (result.type === "common") && token && |
| 110 | (token.type === t[i + 1]?.type) && /\s+/.test(result.value) |
| 111 | ) { |
| 112 | return { |
| 113 | ...result, |
| 114 | type: token.type, |
| 115 | }; |
| 116 | } |
| 117 | return result; |
| 118 | }); |
| 119 | } |
| 120 | |
| 121 | const NON_WHITESPACE_REGEXP = /\S/; |
| 122 | |