@volar/vscode 2.2.0-alpha.1 → 2.2.0-alpha.10
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.
|
@@ -32,9 +32,6 @@ function activate(selector, client) {
|
|
|
32
32
|
if (document !== activeDocument) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
-
if (timeout) {
|
|
36
|
-
clearTimeout(timeout);
|
|
37
|
-
}
|
|
38
35
|
const lastChange = contentChanges[contentChanges.length - 1];
|
|
39
36
|
doAutoInsert(document, lastChange);
|
|
40
37
|
}
|
|
@@ -44,42 +41,35 @@ function activate(selector, client) {
|
|
|
44
41
|
timeout = undefined;
|
|
45
42
|
}
|
|
46
43
|
const version = document.version;
|
|
44
|
+
const isCancel = () => document !== vscode.window.activeTextEditor?.document
|
|
45
|
+
|| vscode.window.activeTextEditor?.document.version !== version;
|
|
47
46
|
timeout = setTimeout(async () => {
|
|
48
47
|
timeout = undefined;
|
|
49
|
-
const isCancel = () => document !== vscode.window.activeTextEditor?.document
|
|
50
|
-
|| vscode.window.activeTextEditor?.document.version !== version;
|
|
51
48
|
if (isCancel()) {
|
|
52
49
|
return;
|
|
53
50
|
}
|
|
54
|
-
const
|
|
55
|
-
|
|
51
|
+
const activeEditor = vscode.window.activeTextEditor;
|
|
52
|
+
if (!activeEditor) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const newTextRange = new vscode.Range(lastChange.range.start, document.positionAt(document.offsetAt(lastChange.range.start)
|
|
56
|
+
+ lastChange.text.length));
|
|
57
|
+
const selection = activeEditor.selections.find(selection => newTextRange.contains(selection.active))?.active;
|
|
58
|
+
if (!selection) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
56
61
|
const params = {
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(document),
|
|
63
|
+
selection: client.code2ProtocolConverter.asPosition(selection),
|
|
64
|
+
change: {
|
|
65
|
+
rangeLength: lastChange.rangeLength,
|
|
66
|
+
rangeOffset: lastChange.rangeOffset,
|
|
59
67
|
text: lastChange.text,
|
|
60
|
-
range: client.code2ProtocolConverter.asRange(lastChange.range),
|
|
61
68
|
},
|
|
62
69
|
};
|
|
63
70
|
const insertion = await client.sendRequest(protocol_1.AutoInsertRequest.type, params);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
&& insertion !== null
|
|
67
|
-
&& isEnabled
|
|
68
|
-
&& !isCancel()
|
|
69
|
-
&& activeEditor) {
|
|
70
|
-
if (typeof insertion === 'string') {
|
|
71
|
-
const selections = activeEditor.selections;
|
|
72
|
-
if (selections.length && selections.some(s => s.active.isEqual(position))) {
|
|
73
|
-
activeEditor.insertSnippet(new vscode.SnippetString(insertion), selections.map(s => s.active));
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
activeEditor.insertSnippet(new vscode.SnippetString(insertion), position);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
const edit = client.protocol2CodeConverter.asTextEdit(insertion);
|
|
81
|
-
activeEditor.insertSnippet(new vscode.SnippetString(edit.newText), edit.range);
|
|
82
|
-
}
|
|
71
|
+
if (insertion && isEnabled && !isCancel()) {
|
|
72
|
+
activeEditor.insertSnippet(new vscode.SnippetString(insertion));
|
|
83
73
|
}
|
|
84
74
|
}, 100);
|
|
85
75
|
}
|
package/lib/features/tsconfig.js
CHANGED
|
@@ -8,8 +8,12 @@ function activate(selector, cmd, client) {
|
|
|
8
8
|
const subscriptions = [];
|
|
9
9
|
const statusBar = vscode.languages.createLanguageStatusItem(cmd, selector);
|
|
10
10
|
let currentTsconfigUri;
|
|
11
|
+
let updateStatus;
|
|
11
12
|
updateStatusBar();
|
|
12
|
-
vscode.window.onDidChangeActiveTextEditor(
|
|
13
|
+
vscode.window.onDidChangeActiveTextEditor(() => {
|
|
14
|
+
clearTimeout(updateStatus);
|
|
15
|
+
updateStatus = setTimeout(() => updateStatusBar, 100);
|
|
16
|
+
}, undefined, subscriptions);
|
|
13
17
|
subscriptions.push(vscode.commands.registerCommand(cmd, async () => {
|
|
14
18
|
if (currentTsconfigUri) {
|
|
15
19
|
const document = await vscode.workspace.openTextDocument(currentTsconfigUri);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/vscode",
|
|
3
|
-
"version": "2.2.0-alpha.
|
|
3
|
+
"version": "2.2.0-alpha.10",
|
|
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.2.0-alpha.
|
|
15
|
+
"@volar/language-server": "2.2.0-alpha.10",
|
|
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": "aedd2230883c457f703be93ed150917a3efde75c"
|
|
26
26
|
}
|