feat(language-server): add tag folding and linked editing
This commit is contained in:
@@ -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 `>`.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user