| 216 | // The inverse of countColumn -- find the offset that corresponds to |
| 217 | // a particular column. |
| 218 | function findColumn(string, goal, tabSize) { |
| 219 | for (var pos = 0, col = 0;;) { |
| 220 | var nextTab = string.indexOf("\t", pos); |
| 221 | if (nextTab == -1) { nextTab = string.length; } |
| 222 | var skipped = nextTab - pos; |
| 223 | if (nextTab == string.length || col + skipped >= goal) |
| 224 | { return pos + Math.min(skipped, goal - col) } |
| 225 | col += nextTab - pos; |
| 226 | col += tabSize - (col % tabSize); |
| 227 | pos = nextTab + 1; |
| 228 | if (col >= goal) { return pos } |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | var spaceStrs = [""]; |
| 233 | function spaceStr(n) { |