feat(language-server): add tag folding and linked editing
This commit is contained in:
1 parent
bd0c1317ff
commit
d9e8f5be82
5 files changed
+149
-2
No files matched your search
@@ -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