(string, end, tabSize, startIndex, startValue)
| 14 | // Counts the column offset in a string, taking tabs into account. |
| 15 | // Used mostly to find indentation. |
| 16 | export function countColumn(string, end, tabSize, startIndex, startValue) { |
| 17 | if (end == null) { |
| 18 | end = string.search(/[^\s\u00a0]/) |
| 19 | if (end == -1) end = string.length |
| 20 | } |
| 21 | for (let i = startIndex || 0, n = startValue || 0;;) { |
| 22 | let nextTab = string.indexOf("\t", i) |
| 23 | if (nextTab < 0 || nextTab >= end) |
| 24 | return n + (end - i) |
| 25 | n += nextTab - i |
| 26 | n += tabSize - (n % tabSize) |
| 27 | i = nextTab + 1 |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | export class Delayed { |
| 32 | constructor() { |
no test coverage detected