extensions/emmet/src/selectItemStylesheet.ts/prevItemStylesheet
export function prevItemStylesheet(document: vscode.TextDocument, startPosition: vscode.Position, endPosition: vscode.Position, rootNode: CssNode): vscode.Selection | undefined {
	const startOffset = document.offsetAt(startPosition);
	const endOffset = document.offsetAt(endPosition);
	let currentNode = <CssNode>getFlatNode(rootNode, startOffset, false);
	if (!currentNode) {
		currentNode = rootNode;
	}
	if (!currentNode) {
		return;
	}

	// Full property value is selected, so select the whole property next
	if (currentNode.type === 'property' &&
		startOffset === (<Property>currentNode).valueToken.start &&
		endOffset === (<Property>currentNode).valueToken.end) {
		return getSelectionFromNode(document, currentNode);
	}

	// Part of propertyValue is selected, so select the prev word in the propertyValue
	if (currentNode.type === 'property' &&
		startOffset >= (<Property>currentNode).valueToken.start &&
		endOffset <= (<Property>currentNode).valueToken.end) {
		let singlePropertyValue = getSelectionFromProperty(document, currentNode, startOffset, endOffset, false, 'prev');
		if (singlePropertyValue) {
			return singlePropertyValue;
		}
	}

	if (currentNode.type === 'property' || !currentNode.firstChild ||
		(currentNode.type === 'rule' && startOffset <= currentNode.firstChild.start)) {
		return getSelectionFromNode(document, currentNode);
	}

	// Select the child that appears just before the cursor
	let prevNode: CssNode | undefined = currentNode.firstChild;
	while (prevNode.nextSibling && startOffset >= prevNode.nextSibling.end) {
		prevNode = prevNode.nextSibling;
	}
	prevNode = <CssNode | undefined>getDeepestFlatNode(prevNode);

	return getSelectionFromProperty(document, prevNode, startOffset, endOffset, false, 'prev');
}