extensions/emmet/src/toggleComment.ts/adjustEndNodeCss
function adjustEndNodeCss(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.end;
	}

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

	if (offset > rule.children[rule.children.length - 1].end) {
		return offset;
	}

	let newEndNode = rule.children[rule.children.length - 1];
	while (newEndNode.previousSibling && offset < newEndNode.start) {
		newEndNode = newEndNode.previousSibling;
	}

	return newEndNode.end;
}