| 724 | // The inverse of countColumn -- find the offset that corresponds to |
| 725 | // a particular column. |
| 726 | function findColumn(string, goal, tabSize) { |
| 727 | for (var pos = 0, col = 0; ; ) { |
| 728 | var nextTab = string.indexOf("\t", pos) |
| 729 | if (nextTab == -1) { |
| 730 | nextTab = string.length |
| 731 | } |
| 732 | var skipped = nextTab - pos |
| 733 | if (nextTab == string.length || col + skipped >= goal) { |
| 734 | return pos + Math.min(skipped, goal - col) |
| 735 | } |
| 736 | col += nextTab - pos |
| 737 | col += tabSize - (col % tabSize) |
| 738 | pos = nextTab + 1 |
| 739 | if (col >= goal) { |
| 740 | return pos |
| 741 | } |
| 742 | } |
| 743 | } |
| 744 | |
| 745 | var spaceStrs = [""] |
| 746 | function spaceStr(n) { |