volar-service-html 0.0.64 → 0.0.66

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 (3) hide show
  1. package/index.d.ts +0 -2
  2. package/index.js +14 -16
  3. package/package.json +2 -2
package/index.d.ts CHANGED
@@ -16,8 +16,6 @@ export declare function create({ documentSelector, configurationSections, useDef
16
16
  };
17
17
  useDefaultDataProvider?: boolean;
18
18
  isFormattingEnabled?(document: TextDocument, context: LanguageServiceContext): ProviderResult<boolean>;
19
- isAutoCreateQuotesEnabled?(document: TextDocument, context: LanguageServiceContext): ProviderResult<boolean>;
20
- isAutoClosingTagsEnabled?(document: TextDocument, context: LanguageServiceContext): ProviderResult<boolean>;
21
19
  getDocumentContext?(context: LanguageServiceContext): html.DocumentContext;
22
20
  getFormattingOptions?(document: TextDocument, options: FormattingOptions, context: LanguageServiceContext): ProviderResult<html.HTMLFormatConfiguration>;
23
21
  getCompletionConfiguration?(document: TextDocument, context: LanguageServiceContext): ProviderResult<html.CompletionConfiguration | undefined>;
package/index.js CHANGED
@@ -306,28 +306,26 @@ function create({ documentSelector = ['html'], configurationSections = {
306
306
  return { ranges };
307
307
  });
308
308
  },
309
- async provideAutoInsertSnippet(document, selection, change) {
309
+ async provideAutoInsertSnippet(document, selection, lastChange) {
310
310
  // selection must at end of change
311
- if (document.offsetAt(selection) !== change.rangeOffset + change.text.length) {
311
+ if (document.offsetAt(selection) !== lastChange.rangeOffset + lastChange.text.length) {
312
312
  return;
313
313
  }
314
314
  return worker(document, async (htmlDocument) => {
315
- if (change.rangeLength === 0 && change.text.endsWith('=')) {
316
- const enabled = await context.env.getConfiguration?.(configurationSections.autoCreateQuotes) ?? true;
317
- if (enabled) {
318
- const completionConfiguration = await getCompletionConfiguration(document, context);
319
- const text = htmlLs.doQuoteComplete(document, selection, htmlDocument, completionConfiguration);
320
- if (text) {
321
- return text;
315
+ if (lastChange.rangeLength === 0 && !/\n/.test(lastChange.text)) {
316
+ if (lastChange.text.endsWith('=')) {
317
+ const enabled = await context.env.getConfiguration?.(configurationSections.autoCreateQuotes) ?? true;
318
+ if (enabled) {
319
+ const completionConfiguration = await getCompletionConfiguration(document, context);
320
+ const text = htmlLs.doQuoteComplete(document, selection, htmlDocument, completionConfiguration);
321
+ return text ?? undefined;
322
322
  }
323
323
  }
324
- }
325
- if (change.rangeLength === 0 && (change.text.endsWith('>') || change.text.endsWith('/'))) {
326
- const enabled = await context.env.getConfiguration?.(configurationSections.autoClosingTags) ?? true;
327
- if (enabled) {
328
- const text = htmlLs.doTagComplete(document, selection, htmlDocument);
329
- if (text) {
330
- return text;
324
+ if (lastChange.text.endsWith('>') || lastChange.text.endsWith('/')) {
325
+ const enabled = await context.env.getConfiguration?.(configurationSections.autoClosingTags) ?? true;
326
+ if (enabled) {
327
+ const text = htmlLs.doTagComplete(document, selection, htmlDocument);
328
+ return text ?? undefined;
331
329
  }
332
330
  }
333
331
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volar-service-html",
3
- "version": "0.0.64",
3
+ "version": "0.0.66",
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",
@@ -39,5 +39,5 @@
39
39
  "optional": true
40
40
  }
41
41
  },
42
- "gitHead": "54e88dafd9bd29cec0e921cfd6c0425b9e222e53"
42
+ "gitHead": "7113cd822bff8839f54ec8dfb3cb9c0486716230"
43
43
  }