volar-service-emmet
Advanced tools
Comparing version 0.0.30 to 0.0.31
19
index.js
@@ -5,3 +5,18 @@ "use strict"; | ||
const emmet = require("@vscode/emmet-helper"); | ||
const volar_service_html_1 = require("volar-service-html"); | ||
const html = require("vscode-html-languageservice"); | ||
const htmlDocuments = new WeakMap(); | ||
let htmlLs; | ||
function getHtmlDocument(document) { | ||
const cache = htmlDocuments.get(document); | ||
if (cache) { | ||
const [cacheVersion, cacheDoc] = cache; | ||
if (cacheVersion === document.version) { | ||
return cacheDoc; | ||
} | ||
} | ||
htmlLs ??= html.getLanguageService(); | ||
const doc = htmlLs.parseHTMLDocument(document); | ||
htmlDocuments.set(document, [document.version, doc]); | ||
return doc; | ||
} | ||
function create() { | ||
@@ -21,3 +36,3 @@ return { | ||
if (syntax === 'html') { | ||
const htmlDocument = (0, volar_service_html_1.getHtmlDocument)(textDocument); | ||
const htmlDocument = getHtmlDocument(textDocument); | ||
const node = htmlDocument.findNodeAt(textDocument.offsetAt(position)); | ||
@@ -24,0 +39,0 @@ if (node.tag) { |
{ | ||
"name": "volar-service-emmet", | ||
"version": "0.0.30", | ||
"version": "0.0.31", | ||
"description": "Integrate @vscode/emmet-helper into Volar", | ||
@@ -28,6 +28,6 @@ "homepage": "https://github.com/volarjs/services/tree/master/packages/emmet", | ||
"@vscode/emmet-helper": "^2.9.2", | ||
"volar-service-html": "0.0.30" | ||
"vscode-html-languageservice": "^5.1.0" | ||
}, | ||
"peerDependencies": { | ||
"@volar/language-service": "~2.0.1" | ||
"@volar/language-service": "~2.1.0" | ||
}, | ||
@@ -42,3 +42,3 @@ "peerDependenciesMeta": { | ||
}, | ||
"gitHead": "30c3cc3c76e90f75f14fe0c2fa4fd33b7ff06507" | ||
"gitHead": "f7005aef724767786ee9fe943fa976231cc79bf1" | ||
} |
7182
101
+ Added@volar/language-core@2.1.6(transitive)
+ Added@volar/language-service@2.1.6(transitive)
+ Added@volar/source-map@2.1.6(transitive)
- Removedvolar-service-html@0.0.30
- Removed@volar/language-core@2.0.4(transitive)
- Removed@volar/language-service@2.0.4(transitive)
- Removed@volar/source-map@2.0.4(transitive)
- Removedvolar-service-html@0.0.30(transitive)