MCPcopy Create free account
hub / github.com/TruthHun/BookStack / findColumn

Function findColumn

static/editor.md/lib/codemirror/lib/codemirror.js:8044–8056  ·  view source on GitHub ↗
(string, goal, tabSize)

Source from the content-addressed store, hash-verified

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) {

Callers 1

extendToFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected