computes start and end position of substring of line that is the
        command string under given position
189206
def get_context(line, pos):
        
        commands = split_commandline(line) + ['']
        i = 0
        start = 0
        end = len(commands[i])
        while pos > end:
            i += 1
            start = end + 1
            end += 1 + len(commands[i])
        return start, end
212654
public String substring(int start, int end) {

    return new String(this.buffer, this.initialOffset + start, end - start);
  }
1018419
public int indexOf(BinaryString subStr, int start) {
		ensureMaterialized();
		subStr.ensureMaterialized();
		if (subStr.sizeInBytes == 0) {
			return 0;
		}
		if (inFirstSegment()) {
			// position in byte
			int byteIdx = 0;
			// position is char
			int charIdx = 0;
			while (byteIdx < sizeInBytes && charIdx < start) {
				byteIdx += numBytesForFirstByte(getByteOneSegment(byteIdx));
				charIdx++;
			}
			do {
				if (byteIdx + subStr.sizeInBytes > sizeInBytes) {
					return -1;
				}
				if (SegmentsUtil.equals(segments, offset + byteIdx,
					subStr.segments, subStr.offset, subStr.sizeInBytes)) {
					return charIdx;
				}
				byteIdx += numBytesForFirstByte(getByteOneSegment(byteIdx));
				charIdx++;
			} while (byteIdx < sizeInBytes);

			return -1;
		} else {
			return indexOfSlow(subStr, start);
		}
	}
208275
def _string_remove_slice(input_str, start, end):
        
        if 0 <= start < end <= len(input_str):
            return input_str[:start] + input_str[end:]
        return input_str
1311693
def _selectedLinesRange(self):
        
        (startLine, startCol), (endLine, endCol) = self._qpart.selectedPosition
        start = min(startLine, endLine)
        end = max(startLine, endLine)
        return start, end
896466
private int parseEndOfLine(String headerPart, int end) {
        int index = end;
        for (; ;) {
            int offset = headerPart.indexOf('\r', index);
            if (offset == -1 || offset + 1 >= headerPart.length()) {
                throw new IllegalStateException("Expected headers to be terminated by an empty line.");
            }
            if (headerPart.charAt(offset + 1) == '\n') {
                return offset;
            }
            index = offset + 1;
        }
    }
784841
def _afterpoint(string):
    
    if _isnumber(string):
        if _isint(string):
            return -1
        else:
            pos = string.rfind(".")
            pos = string.lower().rfind("e") if pos < 0 else pos
            if pos >= 0:
                return len(string) - pos - 1
            else:
                return -1  # no point
    else:
        return -1
551122
protected final int nextStringEndPos(byte[] bytes, int startPos, int limit, byte[] delimiter) {
		int endPos = startPos;

		final int delimLimit = limit - delimiter.length + 1;

		while (endPos < limit) {
			if (endPos < delimLimit && delimiterNext(bytes, endPos, delimiter)) {
				break;
			}
			endPos++;
		}

		if (endPos == startPos) {
			setErrorState(ParseErrorState.EMPTY_COLUMN);
			return -1;
		}
		return endPos;
	}
545194
function (chunks, start, end) {
    var soff=0, eoff=0, i=0, j=0;
    for (i=0; i<chunks.length; i++) {
      if (soff + chunks[i].length > start)
        break;
      soff += chunks[i].length;
    }
    var strs = [];
    eoff = soff;
    for (j=i; j<chunks.length; j++) {
      strs.push(chunks[j]);
      if (eoff + chunks[j].length > end)
        break;
      eoff += chunks[j].length;
    }
    var s = strs.join('');
    return s.substring(start-soff, start-soff+(end-start));
  }
1154183
function(str, end) {
    return (str.length >= end.length &&
            str.substring(str.length - end.length) === end);
  }
1303406
function positionToOffset(str, desiredLine, desiredCol) {
    if (desiredLine === 1) {
        return desiredCol - 1;
    }
    let line = 1;
    let lastNewLineOffset = -1;
    do {
        if (desiredLine === line) {
            return lastNewLineOffset + 1 + desiredCol - 1;
        }
        lastNewLineOffset = str.indexOf('\n', lastNewLineOffset + 1);
        line++;
    } while (lastNewLineOffset >= 0);
    return -1;
}
264035
private void matchEndLine() {
		// First, parse all whitespace characters except for new lines
		index = skipLineSpace(index);

		// Second, check whether we've reached the end-of-file (as signaled by
		// running out of tokens), or we've encountered some token which not a
		// newline.
		if (index >= tokens.size()) {
			return; // EOF
		} else if (tokens.get(index).kind != NewLine) {
			syntaxError("expected end-of-line", tokens.get(index));
		} else {
			index = index + 1;
		}
	}
811737
function stringify(start, end) {
  var values = []
  var positions = []
  var offsets = []

  add(start)
  add(end)

  if (positions.length !== 0) {
    values.push(positions.join('-'))
  }

  if (offsets.length !== 0) {
    values.push(offsets.join('-'))
  }

  return values.join(', ')

  // Add a position.
  function add(position) {
    var tuple = compile(position)

    if (tuple) {
      positions.push(tuple[0])

      if (tuple[1]) {
        offsets.push(tuple[1])
      }
    }
  }
}
824357
def find_matching_bracket_position(self, start_pos=None, end_pos=None):
        

        # Look for a match.
        for A, B in '()', '[]', '{}', '<>':
            if self.current_char == A:
                return self.find_enclosing_bracket_right(A, B, end_pos=end_pos) or 0
            elif self.current_char == B:
                return self.find_enclosing_bracket_left(A, B, start_pos=start_pos) or 0

        return 0
371969
function whitespaceEndPos( $tpl, &$text, $currentPosition, $textLength )
    {
        if ( $currentPosition >= $textLength )
            return $currentPosition;
        while( $currentPosition < $textLength and
               ( $text[$currentPosition] === ' '
                 or $text[$currentPosition] === "\n"
                 or $text[$currentPosition] === "\t"
                 or $text[$currentPosition] === "\r" ) )
        {
            ++$currentPosition;
        }
        return $currentPosition;
    }
393111
private int findIndex(String line) {

        int index = -1;

        if (line == null) {
            return index;
        }

        String trimmedLine = line.trim();
        int spaceIndex = trimmedLine.indexOf(" ");
        int tabIndex = trimmedLine.indexOf("\t");

        if (spaceIndex != -1) {
            if (tabIndex != -1) {
                if (spaceIndex < tabIndex) {
                    index = spaceIndex;
                } else {
                    index = tabIndex;
                }
            } else {
                index = spaceIndex;
            }
        } else {
            index = tabIndex;
        }
        return index;
    }
771057
def word_at_position(self, position):
        """"""
        if position['line'] >= len(self.lines):
            return ''

        line = self.lines[position['line']]
        i = position['character']
        # Split word in two
        start = line[:i]
        end = line[i:]

        # Take end of start and start of end to find word
        # These are guaranteed to match, even if they match the empty string
        m_start = RE_START_WORD.findall(start)
        m_end = RE_END_WORD.findall(end)

        return m_start[0] + m_end[-1]