diff --git a/packages/html/src/index.ts b/packages/html/src/index.ts
index ca2e80f8..3d5b0d93 100644
--- a/packages/html/src/index.ts
+++ b/packages/html/src/index.ts
@@ -147,12 +147,7 @@ export function create({
provideDocumentSymbols(document) {
return worker(document, (htmlDocument) => {
- // TODO: wait for https://github.com/microsoft/vscode-html-languageservice/pull/152
- const symbols: DocumentSymbol[] = [];
- htmlDocument.roots.forEach(node => {
- provideFileSymbolsInternal(document, node, symbols);
- });
- return symbols;
+ return htmlLs.findDocumentSymbols2(document, htmlDocument);
});
},
@@ -358,44 +353,3 @@ const NL = '\n'.charCodeAt(0);
function isNewlineCharacter(charCode: number) {
return charCode === CR || charCode === NL;
}
-
-function provideFileSymbolsInternal(document: TextDocument, node: html.Node, symbols: DocumentSymbol[]): void {
-
- const name = nodeToName(node);
- const range = {
- start: document.positionAt(node.start),
- end: document.positionAt(node.end),
- };
- const symbol: DocumentSymbol = {
- name,
- kind: 8 satisfies typeof SymbolKind.Field,
- range,
- selectionRange: range,
- };
-
- symbols.push(symbol);
-
- node.children.forEach(child => {
- symbol.children ??= [];
- provideFileSymbolsInternal(document, child, symbol.children);
- });
-}
-
-function nodeToName(node: html.Node): string {
- let name = node.tag;
-
- if (node.attributes) {
- const id = node.attributes['id'];
- const classes = node.attributes['class'];
-
- if (id) {
- name += `#${id.replace(/[\"\']/g, '')}`;
- }
-
- if (classes) {
- name += classes.replace(/[\"\']/g, '').split(/\s+/).map(className => `.${className}`).join('');
- }
- }
-
- return name || '?';
-}