MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / findColumn

Function findColumn

lib/web/CodeMirror/src/util/misc.js:75–87  ·  view source on GitHub ↗
(string, goal, tabSize)

Source from the content-addressed store, hash-verified

73// The inverse of countColumn -- find the offset that corresponds to
74// a particular column.
75export function findColumn(string, goal, tabSize) {
76 for (let pos = 0, col = 0;;) {
77 let nextTab = string.indexOf("\t", pos)
78 if (nextTab == -1) nextTab = string.length
79 let skipped = nextTab - pos
80 if (nextTab == string.length || col + skipped >= goal)
81 return pos + Math.min(skipped, goal - col)
82 col += nextTab - pos
83 col += tabSize - (col % tabSize)
84 pos = nextTab + 1
85 if (col >= goal) return pos
86 }
87}
88
89let spaceStrs = [""]
90export function spaceStr(n) {

Callers 1

extendToFunction · 0.90

Calls 2

indexOfMethod · 0.80
minMethod · 0.45

Tested by

no test coverage detected