src/vs/editor/common/model/pieceTreeTextBuffer/pieceTreeBase.ts/PieceTreeBase/findMatchesInNode
class PieceTreeBase:	public findMatchesInNode(node: TreeNode, searcher: Searcher, startLineNumber: number, startColumn: number, startCursor: BufferCursor, endCursor: BufferCursor, searchData: SearchData, captureMatches: boolean, limitResultCount: number, resultLen: number, result: FindMatch[]) {
		const buffer = this._buffers[node.piece.bufferIndex];
		const startOffsetInBuffer = this.offsetInBuffer(node.piece.bufferIndex, node.piece.start);
		const start = this.offsetInBuffer(node.piece.bufferIndex, startCursor);
		const end = this.offsetInBuffer(node.piece.bufferIndex, endCursor);

		let m: RegExpExecArray | null;
		// Reset regex to search from the beginning
		const ret: BufferCursor = { line: 0, column: 0 };
		let searchText: string;
		let offsetInBuffer: (offset: number) => number;

		if (searcher._wordSeparators) {
			searchText = buffer.buffer.substring(start, end);
			offsetInBuffer = (offset: number) => offset + start;
			searcher.reset(0);
		} else {
			searchText = buffer.buffer;
			offsetInBuffer = (offset: number) => offset;
			searcher.reset(start);
		}

		do {
			m = searcher.next(searchText);

			if (m) {
				if (offsetInBuffer(m.index) >= end) {
					return resultLen;
				}
				this.positionInBuffer(node, offsetInBuffer(m.index) - startOffsetInBuffer, ret);
				const lineFeedCnt = this.getLineFeedCnt(node.piece.bufferIndex, startCursor, ret);
				const retStartColumn = ret.line === startCursor.line ? ret.column - startCursor.column + startColumn : ret.column + 1;
				const retEndColumn = retStartColumn + m[0].length;
				result[resultLen++] = createFindMatch(new Range(startLineNumber + lineFeedCnt, retStartColumn, startLineNumber + lineFeedCnt, retEndColumn), m, captureMatches);

				if (offsetInBuffer(m.index) + m[0].length >= end) {
					return resultLen;
				}
				if (resultLen >= limitResultCount) {
					return resultLen;
				}
			}

		} while (m);

		return resultLen;
	}