volar-service-html 0.0.37 → 0.0.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +9 -8
  2. package/package.json +4 -4
package/index.js CHANGED
@@ -263,25 +263,26 @@ function create({ documentSelector = ['html'], useDefaultDataProvider = true, ge
263
263
  return { ranges };
264
264
  });
265
265
  },
266
- async provideAutoInsertionEdit(document, position, lastChange) {
266
+ async provideAutoInsertionEdit(document, selection, change) {
267
+ // selection must at end of change
268
+ if (document.offsetAt(selection) !== change.rangeOffset + change.text.length) {
269
+ return;
270
+ }
267
271
  return worker(document, async (htmlDocument) => {
268
- const lastCharacter = lastChange.text[lastChange.text.length - 1];
269
- const rangeLengthIsZero = lastChange.range.start.line === lastChange.range.end.line
270
- && lastChange.range.start.character === lastChange.range.end.character;
271
- if (rangeLengthIsZero && lastCharacter === '=') {
272
+ if (change.rangeLength === 0 && change.text.endsWith('=')) {
272
273
  const enabled = await isAutoCreateQuotesEnabled(document, context);
273
274
  if (enabled) {
274
275
  const completionConfiguration = await getCompletionConfiguration(document, context);
275
- const text = htmlLs.doQuoteComplete(document, position, htmlDocument, completionConfiguration);
276
+ const text = htmlLs.doQuoteComplete(document, selection, htmlDocument, completionConfiguration);
276
277
  if (text) {
277
278
  return text;
278
279
  }
279
280
  }
280
281
  }
281
- if (rangeLengthIsZero && (lastCharacter === '>' || lastCharacter === '/')) {
282
+ if (change.rangeLength === 0 && (change.text.endsWith('>') || change.text.endsWith('/'))) {
282
283
  const enabled = await isAutoClosingTagsEnabled(document, context);
283
284
  if (enabled) {
284
- const text = htmlLs.doTagComplete(document, position, htmlDocument);
285
+ const text = htmlLs.doTagComplete(document, selection, htmlDocument);
285
286
  if (text) {
286
287
  return text;
287
288
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volar-service-html",
3
- "version": "0.0.37",
3
+ "version": "0.0.39",
4
4
  "description": "Integrate vscode-languageservice-html into Volar",
5
5
  "homepage": "https://github.com/volarjs/services/tree/master/packages/html",
6
6
  "bugs": "https://github.com/volarjs/services/issues",
@@ -24,7 +24,7 @@
24
24
  "url": "https://github.com/johnsoncodehk"
25
25
  },
26
26
  "dependencies": {
27
- "vscode-html-languageservice": "^5.1.0",
27
+ "vscode-html-languageservice": "npm:@johnsoncodehk/vscode-html-languageservice@5.2.0-34a5462",
28
28
  "vscode-languageserver-textdocument": "^1.0.11",
29
29
  "vscode-uri": "^3.0.8"
30
30
  },
@@ -32,12 +32,12 @@
32
32
  "@types/node": "latest"
33
33
  },
34
34
  "peerDependencies": {
35
- "@volar/language-service": "~2.2.0-alpha.1"
35
+ "@volar/language-service": "~2.2.0-alpha.4"
36
36
  },
37
37
  "peerDependenciesMeta": {
38
38
  "@volar/language-service": {
39
39
  "optional": true
40
40
  }
41
41
  },
42
- "gitHead": "ee14afba19f419a31c4b70e5a34f88cefb59ac49"
42
+ "gitHead": "69bf117b9fddb1d485396d484948485183c6d40a"
43
43
  }