| 8042 | // The inverse of countColumn -- find the offset that corresponds to |
| 8043 | // a particular column. |
| 8044 | function findColumn(string, goal, tabSize) { |
| 8045 | for (var pos = 0, col = 0;;) { |
| 8046 | var nextTab = string.indexOf("\t", pos); |
| 8047 | if (nextTab == -1) nextTab = string.length; |
| 8048 | var skipped = nextTab - pos; |
| 8049 | if (nextTab == string.length || col + skipped >= goal) |
| 8050 | return pos + Math.min(skipped, goal - col); |
| 8051 | col += nextTab - pos; |
| 8052 | col += tabSize - (col % tabSize); |
| 8053 | pos = nextTab + 1; |
| 8054 | if (col >= goal) return pos; |
| 8055 | } |
| 8056 | } |
| 8057 | |
| 8058 | var spaceStrs = [""]; |
| 8059 | function spaceStr(n) { |