Change:
<!-- Do Not Delete This! bugreporttemplate --<!-- Please read our Rules of Conduct: --<!-- Please search existing issues to avoid creating duplicates. --<!-- Also please test using the latest insiders build to make sure your issue has not already been fixed: --<!-- Use Help Report Issue to prefill these. --- VSCode Version: 1.46 OS Version: Win 8.1 Steps to Reproduce: a HTML file with the following content the cursor after the command tag is removed but also everything is unindented 1 step If you do the process by hand: <kbdCtrl</kbd+<kbdX</kbd<kbdCtrl</kbd+<kbdV</kbdresult is correct <!-- Launch with to check. --Does this issue occur when all extensions are disabled?: Yes
I am interested in this and would be working on it.
VsCode implementation just removes an indent/tag (exactly one indent i.e a tab or x spaces) at the start of the line for the lines in between the tags opening and closing(if there is enough blank space) Testing the behavior here , it is clear that the content should be adjusted for indentation if the indentation of content is more than that of tags. Also, if there is an adjustment needed, the adjustment should be the difference in the indent levels not just plainly one indent.
I have configured VSC to not create any indent for any tag. Also this is inside a pre tag so no indentation modification should be done. It could also be a span tag that changes the color of the code in the pre tag. a code tag is not a tag that modifies indentation.
I'm not very familiar with this part of Emmet functionality yet. Will take a look at the PR after patching up some other parts of Emmet.
This bug has been fixed in to the latest release of ! you can help us out by confirming things are working as expected in the latest Insiders release. If things look good, please leave a comment with the text to let us know. If not, please ensure you're on version of Insiders (today's or later - you can use in the command palette to check), and leave a comment letting us know what isn't working as expected. Happy Coding!

Discussion:
*--------------------------------------------------------------------------------------------*/ import * as vscode from 'vscode'; <del> import { parseDocument, validate, getHtmlNode } from './util'; import { HtmlNode } from 'EmmetNode'; </del> <ins> import { validate, getHtmlNodeLS, toLSTextDocument, offsetRangeToVsRange } from './util'; </ins> export function removeTag() { if (!validate(false) || !vscode.window.activeTextEditor) {

} const editor = vscode.window.activeTextEditor; <del> let rootNode = <HtmlNode>parseDocument(editor.document); if (!rootNode) { return; } let indentInSpaces = ''; const tabSize: number = editor.options.tabSize ? +editor.options.tabSize : 0; for (let i = 0; i < tabSize || 0; i++) { indentInSpaces += ' '; } let rangesToRemove: vscode.Range[] = []; editor.selections.reverse().forEach(selection => { rangesToRemove = rangesToRemove.concat(getRangeToRemove(editor, rootNode, selection, indentInSpaces)); }); </del> <ins> const tabSize: number = +editor.options.tabSize!; let finalRangesToRemove = editor.selections.reverse() .reduce<vscode.Range[]>((prev, selection) => prev.concat(getRangesToRemove(editor.document, selection, tabSize)), []); </ins> return editor.edit(editBuilder => { <del> rangesToRemove.forEach(range => { </del> <ins> finalRangesToRemove.forEach(range => { </ins> editBuilder.replace(range, ''); }); }); } <del> function getRangeToRemove(editor: vscode.TextEditor, rootNode: HtmlNode, selection: vscode.Selection, indentInSpaces: string): vscode.Range[] { let nodeToUpdate = getHtmlNode(editor.document, rootNode, selection.start, true); </del> <ins> /** * Calculates the ranges to remove, along with what to replace those ranges with. * It finds the node to remove based on the selection's start position * and then removes that node, reindenting the content in between. * Assumption: The document indents consist of only tabs or only spaces. */ function getRangesToRemove(document: vscode.TextDocument, selection: vscode.Selection, tabSize: number): vscode.Range[] { const lsDocument = toLSTextDocument(document); const nodeToUpdate = getHtmlNodeLS(lsDocument, selection.start, true); </ins> if (!nodeToUpdate) { return []; } <del> let openRange = new vscode.Range(nodeToUpdate.open.start, nodeToUpdate.open.end); let closeRange: vscode.Range | null = null; if (nodeToUpdate.close) { closeRange = new vscode.Range(nodeToUpdate.close.start, nodeToUpdate.close.end); </del> <ins> const openTagRange = offsetRangeToVsRange(lsDocument, nodeToUpdate.start, nodeToUpdate.startTagEnd ?? nodeToUpdate.end); let closeTagRange: vscode.Range | undefined; if (nodeToUpdate.endTagStart !== undefined) { closeTagRange = offsetRangeToVsRange(lsDocument, nodeToUpdate.endTagStart, nodeToUpdate.end); } let rangesToRemove = [openTagRange]; if (closeTagRange) { const indentAmountToRemove = calculateIndentAmountToRemove(document, openTagRange, closeTagRange, tabSize); for (let i = openTagRange.start.line + 1; i < closeTagRange.start.line; i++) { rangesToRemove.push(new vscode.Range(i, 0, i, indentAmountToRemove)); } rangesToRemove.push(closeTagRange); } return rangesToRemove; } type IndentInfo = { indentAmount: number, tabsOnly: boolean }; /** * Calculates the amount of indent to remove for getRangesToRemove. */ function calculateIndentAmountToRemove(document: vscode.TextDocument, openRange: vscode.Range, closeRange: vscode.Range, tabSize: number): number { const startLine = openRange.start.line; const endLine = closeRange.start.line; const startLineIndent = calculateLineIndentInSpaces(document.lineAt(startLine).text, tabSize); const endLineIndent = calculateLineIndentInSpaces(document.lineAt(endLine).text, tabSize); let contentIndent: IndentInfo | undefined; for (let i = startLine + 1; i <= endLine - 1; i++) { const lineContent = document.lineAt(i).text; const indent = calculateLineIndentInSpaces(lineContent, tabSize); contentIndent = !contentIndent ? indent : { indentAmount: Math.min(contentIndent.indentAmount, indent.indentAmount), tabsOnly: contentIndent.tabsOnly && indent.tabsOnly }; </ins> } <del> let ranges = [openRange]; if (closeRange) { for (let i = openRange.start.line + 1; i <= closeRange.start.line; i++) { let lineContent = editor.document.lineAt(i).text; if (lineContent.startsWith('t')) { ranges.push(new vscode.Range(i, 0, i, 1)); } else if (lineContent.startsWith(indentInSpaces)) { ranges.push(new vscode.Range(i, 0, i, indentInSpaces.length)); } </del> <ins> let indentAmountSpaces = 0; let tabsOnly = startLineIndent.tabsOnly && endLineIndent.tabsOnly; if (contentIndent) { if (contentIndent.indentAmount < startLineIndent.indentAmount || contentIndent.indentAmount < endLineIndent.indentAmount) { indentAmountSpaces = 0; </ins> } <del> ranges.push(closeRange); </del> <ins> else { indentAmountSpaces = Math.min( contentIndent.indentAmount - startLineIndent.indentAmount, contentIndent.indentAmount - endLineIndent.indentAmount ); } tabsOnly = tabsOnly && contentIndent.tabsOnly; </ins> } <del> return ranges; </del> <ins> return tabsOnly ? Math.trunc(indentAmountSpaces / tabSize) : indentAmountSpaces; </ins> } <ins> function calculateLineIndentInSpaces(line: string, tabSize: number): IndentInfo { const whiteSpaceMatch = line.match(/^s+/); const whiteSpaceContent = whiteSpaceMatch ? whiteSpaceMatch[0] : ''; if (!whiteSpaceContent) { return { indentAmount: 0, tabsOnly: true }; } let numSpaces = 0; let numTabs = 0; let tabsOnly = true; for (const c of whiteSpaceContent) { if (c === 't') { numTabs++; } else { numSpaces++; tabsOnly = false; } } return { indentAmount: numTabs * tabSize + numSpaces, tabsOnly }; } </ins>

<li><span>Hello</span></li> <li><span>There</span></li> <div><li><span>Bye</span></li></div> <del> t </del> <ins> tt </ins> <span/> </script> `;