@volar/vscode 2.2.4 → 2.3.0-alpha.0
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/index.d.ts +0 -1
- package/lib/features/autoInsertion.js +25 -3
- package/lib/features/tsVersion.d.ts +1 -2
- package/lib/features/tsVersion.js +3 -12
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.activate = void 0;
|
|
4
|
-
const vscode = require("vscode");
|
|
5
4
|
const protocol_1 = require("@volar/language-server/protocol");
|
|
5
|
+
const vscode = require("vscode");
|
|
6
6
|
function activate(selector, client) {
|
|
7
7
|
let isEnabled = false;
|
|
8
8
|
let timeout;
|
|
@@ -41,8 +41,30 @@ function activate(selector, client) {
|
|
|
41
41
|
timeout = undefined;
|
|
42
42
|
}
|
|
43
43
|
const version = document.version;
|
|
44
|
-
const
|
|
45
|
-
|
|
44
|
+
const lastCharacter = lastChange.text[lastChange.text.length - 1];
|
|
45
|
+
const isCancel = () => {
|
|
46
|
+
if (document !== vscode.window.activeTextEditor?.document) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
if (vscode.window.activeTextEditor?.document.version !== version) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
const initializeResult = client.initializeResult;
|
|
53
|
+
if (initializeResult?.autoInsertion) {
|
|
54
|
+
for (let i = 0; i < initializeResult.autoInsertion.triggerCharacters.length; i++) {
|
|
55
|
+
const char = initializeResult.autoInsertion.triggerCharacters[i];
|
|
56
|
+
if (!lastCharacter.match(new RegExp(char))) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const configurationSection = initializeResult.autoInsertion.configurationSections[i];
|
|
60
|
+
if (configurationSection && !vscode.workspace.getConfiguration().get(configurationSection)) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
};
|
|
46
68
|
timeout = setTimeout(async () => {
|
|
47
69
|
timeout = undefined;
|
|
48
70
|
if (isCancel()) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as vscode from 'vscode';
|
|
2
|
-
|
|
3
|
-
export declare function activate(selector: vscode.DocumentSelector, cmd: string, context: vscode.ExtensionContext, client: BaseLanguageClient, resolveStatusText: (text: string) => string): vscode.Disposable;
|
|
2
|
+
export declare function activate(selector: vscode.DocumentSelector, cmd: string, context: vscode.ExtensionContext, resolveStatusText: (text: string) => string, onRestart?: () => void): vscode.Disposable;
|
|
4
3
|
export declare function getTsdk(context: vscode.ExtensionContext): Promise<{
|
|
5
4
|
tsdk: string;
|
|
6
5
|
version: string | undefined;
|
|
@@ -6,7 +6,7 @@ const vscode = require("vscode");
|
|
|
6
6
|
const common_1 = require("../common");
|
|
7
7
|
const fs = require("../fs");
|
|
8
8
|
const defaultTsdkPath = 'node_modules/typescript/lib';
|
|
9
|
-
function activate(selector, cmd, context,
|
|
9
|
+
function activate(selector, cmd, context, resolveStatusText, onRestart) {
|
|
10
10
|
const subscriptions = [];
|
|
11
11
|
const statusBar = vscode.languages.createLanguageStatusItem(cmd, selector);
|
|
12
12
|
statusBar.command = {
|
|
@@ -51,13 +51,13 @@ function activate(selector, cmd, context, client, resolveStatusText) {
|
|
|
51
51
|
const useWorkspaceTsdk = select === 'useConfigWorkspaceTsdk' || select === 'useDefaultWorkspaceTsdk';
|
|
52
52
|
if (useWorkspaceTsdk !== isUseWorkspaceTsdk(context)) {
|
|
53
53
|
context.workspaceState.update('typescript.useWorkspaceTsdk', useWorkspaceTsdk);
|
|
54
|
-
|
|
54
|
+
onRestart?.();
|
|
55
55
|
}
|
|
56
56
|
updateStatusBar();
|
|
57
57
|
}
|
|
58
58
|
function onDidChangeConfiguration(e) {
|
|
59
59
|
if (e.affectsConfiguration('typescript.tsdk') && isUseWorkspaceTsdk(context)) {
|
|
60
|
-
|
|
60
|
+
onRestart?.();
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
async function updateStatusBar() {
|
|
@@ -65,15 +65,6 @@ function activate(selector, cmd, context, client, resolveStatusText) {
|
|
|
65
65
|
statusBar.text = tsVersion ?? 'x.x.x';
|
|
66
66
|
statusBar.text = resolveStatusText(statusBar.text);
|
|
67
67
|
}
|
|
68
|
-
async function reloadServers() {
|
|
69
|
-
const tsPaths = await getTsdk(context);
|
|
70
|
-
const newInitOptions = {
|
|
71
|
-
...client.clientOptions.initializationOptions,
|
|
72
|
-
typescript: tsPaths,
|
|
73
|
-
};
|
|
74
|
-
client.clientOptions.initializationOptions = newInitOptions;
|
|
75
|
-
vscode.commands.executeCommand('volar.action.restartServer');
|
|
76
|
-
}
|
|
77
68
|
}
|
|
78
69
|
exports.activate = activate;
|
|
79
70
|
async function getTsdk(context) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/vscode",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0-alpha.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"directory": "packages/vscode"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@volar/language-server": "2.
|
|
15
|
+
"@volar/language-server": "2.3.0-alpha.0",
|
|
16
16
|
"path-browserify": "^1.0.1",
|
|
17
17
|
"vscode-languageclient": "^9.0.1",
|
|
18
18
|
"vscode-nls": "^5.2.0"
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"@types/path-browserify": "latest",
|
|
23
23
|
"@types/vscode": "^1.82.0"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "f17c19f712651acde33cc2171a112e64db0b460e"
|
|
26
26
|
}
|