MCPcopy Create free account
hub / github.com/breck7/scroll / findColumn

Function findColumn

external/.scrollLibs.js:726–743  ·  view source on GitHub ↗
(string, goal, tabSize)

Source from the content-addressed store, hash-verified

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

Callers 1

extendToFunction · 0.85

Calls 2

indexOfMethod · 0.80
minMethod · 0.80

Tested by

no test coverage detected