extensions/emmet/src/toggleComment.ts/adjustStartNodeCss
function adjustStartNodeCss(node: Node | undefined, offset: number, rootNode: Stylesheet): number {
	for (const comment of rootNode.comments) {
		if (comment.start <= offset && offset <= comment.end) {
			return offset;
		}
	}

	if (!node) {
		return offset;
	}

	if (node.type === 'property') {
		return node.start;
	}

	const rule = <Rule>node;
	if (offset < rule.contentStartToken.end || !rule.firstChild) {
		return rule.start;
	}

	if (offset < rule.firstChild.start) {
		return offset;
	}

	let newStartNode = rule.firstChild;
	while (newStartNode.nextSibling && offset > newStartNode.end) {
		newStartNode = newStartNode.nextSibling;
	}

	return newStartNode.start;
}