* Calculate the visual indentation of a line
(line: string, tabSize: number)
| 63 | * Calculate the visual indentation of a line |
| 64 | */ |
| 65 | function getLineIndentation(line: string, tabSize: number): number { |
| 66 | let columns = 0; |
| 67 | for (const ch of line) { |
| 68 | if (ch === " ") { |
| 69 | columns++; |
| 70 | } else if (ch === "\t") { |
| 71 | columns += tabSize - (columns % tabSize); |
| 72 | } else { |
| 73 | break; |
| 74 | } |
| 75 | } |
| 76 | return columns; |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Check if a line is blank |