volar-service-prettier 0.0.42 → 0.0.43

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 +12 -6
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -6,8 +6,9 @@ function create(
6
6
  /**
7
7
  * Prettier instance or getter to use.
8
8
  */
9
- prettierInstanceOrGetter, { html, documentSelector = ['html', 'css', 'scss', 'typescript', 'javascript'], isFormattingEnabled = async (prettier, document) => {
10
- const uri = vscode_uri_1.URI.parse(document.uri);
9
+ prettierInstanceOrGetter, { html, documentSelector = ['html', 'css', 'scss', 'typescript', 'javascript'], isFormattingEnabled = async (prettier, document, context) => {
10
+ const documentUri = context.decodeEmbeddedDocumentUri(document.uri)?.[0] ?? document.uri;
11
+ const uri = vscode_uri_1.URI.parse(documentUri);
11
12
  if (uri.scheme === 'file') {
12
13
  const fileInfo = await prettier.getFileInfo(uri.fsPath, { ignorePath: '.prettierignore', resolveConfig: false });
13
14
  if (fileInfo.ignored) {
@@ -16,11 +17,16 @@ prettierInstanceOrGetter, { html, documentSelector = ['html', 'css', 'scss', 'ty
16
17
  }
17
18
  return true;
18
19
  }, getFormattingOptions = async (prettier, document, formatOptions, context) => {
19
- const filepath = vscode_uri_1.URI.parse(document.uri).fsPath;
20
- const configOptions = await prettier.resolveConfig(filepath);
21
- const editorOptions = await context.env.getConfiguration?.('prettier', document.uri);
20
+ const documentUri = context.decodeEmbeddedDocumentUri(document.uri)?.[0] ?? document.uri;
21
+ const uri = vscode_uri_1.URI.parse(documentUri);
22
+ const configOptions = uri.scheme === 'file'
23
+ ? await prettier.resolveConfig(uri.fsPath)
24
+ : null;
25
+ const editorOptions = await context.env.getConfiguration?.('prettier', documentUri);
22
26
  return {
23
- filepath,
27
+ filepath: uri.scheme === 'file'
28
+ ? uri.fsPath
29
+ : undefined,
24
30
  tabWidth: formatOptions.tabSize,
25
31
  useTabs: !formatOptions.insertSpaces,
26
32
  ...editorOptions,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volar-service-prettier",
3
- "version": "0.0.42",
3
+ "version": "0.0.43",
4
4
  "description": "Integrate Prettier into Volar",
5
5
  "homepage": "https://github.com/volarjs/services/tree/master/packages/prettier",
6
6
  "bugs": "https://github.com/volarjs/services/issues",
@@ -43,5 +43,5 @@
43
43
  "optional": true
44
44
  }
45
45
  },
46
- "gitHead": "9649e1cc18d7720391567699af9e73f80f076565"
46
+ "gitHead": "391d2dc126cfb541c6b919d9acfa12eb0d6baa26"
47
47
  }