feat(language-server): add tag folding and linked editing

This commit is contained in:
2026-08-18 21:10:57 +05:30
parent bd0c1317ff
commit d9e8f5be82
5 changed files with 149 additions and 2 deletions
@@ -77,6 +77,22 @@ export function htmlFoldingRanges(
.map((range) => ({ startLine: range.startLine, endLine: range.endLine }));
}
/** Ranges of the opening and closing tag names, so renaming one renames both. */
export function htmlLinkedEditingRanges(
document: TextDocument,
position: Position,
): Array<{ start: Position; end: Position }> | null {
if (!isInsideHtml(document, offsetAt(document.text, position))) return null;
const virtual = htmlDocument(document);
const ranges = service.findLinkedEditingRanges(
virtual,
position,
service.parseHTMLDocument(virtual),
);
return ranges && ranges.length ? ranges : null;
}
/**
* Detects `<Name attr="x" /` just before `position` and completes the `>`.
*