volar-service-prettyhtml 0.0.11 → 0.0.12
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.
- package/out/index.d.ts +2 -2
- package/out/index.js +36 -29
- package/package.json +2 -2
package/out/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Service } from '@volar/language-service';
|
|
2
2
|
import prettyhtml from '@starptech/prettyhtml';
|
|
3
|
-
declare
|
|
4
|
-
export default
|
|
3
|
+
export declare function create(configs: NonNullable<Parameters<typeof prettyhtml>[1]>): Service;
|
|
4
|
+
export default create;
|
package/out/index.js
CHANGED
|
@@ -3,35 +3,42 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.create = void 0;
|
|
6
7
|
const prettyhtml_1 = __importDefault(require("@starptech/prettyhtml"));
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
})
|
|
23
|
-
+ newRangeText
|
|
24
|
-
+ document.getText({
|
|
25
|
-
start: range.end,
|
|
26
|
-
end: document.positionAt(document.getText().length),
|
|
27
|
-
});
|
|
28
|
-
return [{
|
|
29
|
-
newText,
|
|
30
|
-
range: {
|
|
8
|
+
function create(configs) {
|
|
9
|
+
return () => {
|
|
10
|
+
return {
|
|
11
|
+
provideDocumentFormattingEdits(document, range, options) {
|
|
12
|
+
if (document.languageId !== 'html')
|
|
13
|
+
return;
|
|
14
|
+
const oldRangeText = document.getText(range);
|
|
15
|
+
const newRangeText = (0, prettyhtml_1.default)(oldRangeText, {
|
|
16
|
+
...configs,
|
|
17
|
+
tabWidth: options.tabSize,
|
|
18
|
+
useTabs: !options.insertSpaces,
|
|
19
|
+
}).contents;
|
|
20
|
+
if (newRangeText === oldRangeText)
|
|
21
|
+
return [];
|
|
22
|
+
const newText = document.getText({
|
|
31
23
|
start: document.positionAt(0),
|
|
32
|
-
end:
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
24
|
+
end: range.start,
|
|
25
|
+
})
|
|
26
|
+
+ newRangeText
|
|
27
|
+
+ document.getText({
|
|
28
|
+
start: range.end,
|
|
29
|
+
end: document.positionAt(document.getText().length),
|
|
30
|
+
});
|
|
31
|
+
return [{
|
|
32
|
+
newText,
|
|
33
|
+
range: {
|
|
34
|
+
start: document.positionAt(0),
|
|
35
|
+
end: document.positionAt(document.getText().length),
|
|
36
|
+
},
|
|
37
|
+
}];
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
exports.create = create;
|
|
43
|
+
exports.default = create;
|
|
37
44
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "volar-service-prettyhtml",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -23,5 +23,5 @@
|
|
|
23
23
|
"optional": true
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "7422c8d99d498df660ff9be3491545a5b45b3622"
|
|
27
27
|
}
|