extensions/emmet/src/removeTag.ts/getRangesToRemove
function getRangesToRemove(document: vscode.TextDocument, rootNode: HtmlFlatNode, selection: vscode.Selection): vscode.Range[] {
	const offset = document.offsetAt(selection.start);
	const nodeToUpdate = getHtmlFlatNode(document.getText(), rootNode, offset, true);
	if (!nodeToUpdate) {
		return [];
	}

	let openTagRange: vscode.Range | undefined;
	if (nodeToUpdate.open) {
		openTagRange = offsetRangeToVsRange(document, nodeToUpdate.open.start, nodeToUpdate.open.end);
	}
	let closeTagRange: vscode.Range | undefined;
	if (nodeToUpdate.close) {
		closeTagRange = offsetRangeToVsRange(document, nodeToUpdate.close.start, nodeToUpdate.close.end);
	}

	if (openTagRange && closeTagRange) {
		const innerCombinedRange = new vscode.Range(
			openTagRange.end.line,
			openTagRange.end.character,
			closeTagRange.start.line,
			closeTagRange.start.character);
		const outerCombinedRange = new vscode.Range(
			openTagRange.start.line,
			openTagRange.start.character,
			closeTagRange.end.line,
			closeTagRange.end.character);
		// Special case: there is only whitespace in between.
		if (document.getText(innerCombinedRange).trim() === '' && nodeToUpdate.name !== 'pre') {
			return [outerCombinedRange];
		}
	}

	let rangesToRemove = [];
	if (openTagRange) {
		rangesToRemove.push(openTagRange);
		if (closeTagRange) {
			const indentAmountToRemove = calculateIndentAmountToRemove(document, openTagRange, closeTagRange);
			let firstInnerNonEmptyLine: number | undefined;
			let lastInnerNonEmptyLine: number | undefined;
			for (let i = openTagRange.start.line + 1; i < closeTagRange.start.line; i++) {
				if (!document.lineAt(i).isEmptyOrWhitespace) {
					rangesToRemove.push(new vscode.Range(i, 0, i, indentAmountToRemove));
					if (firstInnerNonEmptyLine === undefined) {
						// We found the first non-empty inner line.
						firstInnerNonEmptyLine = i;
					}
					lastInnerNonEmptyLine = i;
				}
			}

			// Remove the entire last line + empty lines preceding it
			// if it is just the tag, otherwise remove just the tag.
			if (entireLineIsTag(document, closeTagRange) && lastInnerNonEmptyLine) {
				rangesToRemove.push(new vscode.Range(
					lastInnerNonEmptyLine,
					document.lineAt(lastInnerNonEmptyLine).range.end.character,
					closeTagRange.end.line,
					closeTagRange.end.character));
			} else {
				rangesToRemove.push(closeTagRange);
			}

			// Remove the entire first line + empty lines proceding it
			// if it is just the tag, otherwise keep on removing just the tag.
			if (entireLineIsTag(document, openTagRange) && firstInnerNonEmptyLine) {
				rangesToRemove[1] = new vscode.Range(
					openTagRange.start.line,
					openTagRange.start.character,
					firstInnerNonEmptyLine,
					document.lineAt(firstInnerNonEmptyLine).firstNonWhitespaceCharacterIndex);
				rangesToRemove.shift();
			}
		}
	}
	return rangesToRemove;
}