MCPcopy Index your code
hub / github.com/csev/py4e / scan

Function scan

tools/pythonauto/static/codemirrorepl/codemirrorepl.js:1940–1955  ·  view source on GitHub ↗
(line, from, to)

Source from the content-addressed store, hash-verified

1938
1939 var stack = [line.text.charAt(pos)], re = /[(){}[\]]/;
1940 function scan(line, from, to) {
1941 if (!line.text) return;
1942 var st = line.styles, pos = forward ? 0 : line.text.length - 1, cur;
1943 for (var i = forward ? 0 : st.length - 2, e = forward ? st.length : -2; i != e; i += 2*d) {
1944 var text = st[i];
1945 if (st[i+1] != null && st[i+1] != style) {pos += d * text.length; continue;}
1946 for (var j = forward ? 0 : text.length - 1, te = forward ? text.length : -1; j != te; j += d, pos+=d) {
1947 if (pos >= from && pos < to && re.test(cur = text.charAt(j))) {
1948 var match = matching[cur];
1949 if (match.charAt(1) == ">" == forward) stack.push(cur);
1950 else if (stack.pop() != match.charAt(0)) return {pos: pos, match: false};
1951 else if (!stack.length) return {pos: pos, match: true};
1952 }
1953 }
1954 }
1955 }
1956 for (var i = head.line, e = forward ? Math.min(i + 100, doc.size) : Math.max(-1, i - 100); i != e; i+=d) {
1957 var line = getLine(i), first = i == head.line;
1958 var found = scan(line, first && forward ? pos + 1 : 0, first && !forward ? pos : line.text.length);

Callers 1

matchBracketsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected