Skip to content

Commit cc4b8ce

Browse files
committed
为每个工作区外的lua文件单独启动一个服务
1 parent ff2bca4 commit cc4b8ce

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

client/out/languageserver.js

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/src/languageserver.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ export function activate(context: ExtensionContext) {
171171
// Files outside a folder can't be handled. This might depend on the language.
172172
// Single file languages like JSON might handle files outside the workspace folders.
173173
if (!folder) {
174+
if (!clients.has(uri.toString())) {
175+
let client = start(context, [
176+
{ scheme: 'file', language: 'lua', pattern: `${uri.fsPath}` }
177+
], null);
178+
clients.set(uri.toString(), client);
179+
}
174180
return;
175181
}
176182
// If we have nested workspace folders we only start a server on the outer most workspace folder.
@@ -184,7 +190,19 @@ export function activate(context: ExtensionContext) {
184190
}
185191
}
186192

193+
function didCloseTextDocument(document: TextDocument): void {
194+
let uri = document.uri;
195+
if (clients.has(uri.toString())) {
196+
let client = clients.get(uri.toString());
197+
if (client) {
198+
clients.delete(uri.toString());
199+
client.stop();
200+
}
201+
}
202+
}
203+
187204
Workspace.onDidOpenTextDocument(didOpenTextDocument);
205+
Workspace.onDidCloseTextDocument(didCloseTextDocument);
188206
Workspace.textDocuments.forEach(didOpenTextDocument);
189207
Workspace.onDidChangeWorkspaceFolders((event) => {
190208
for (let folder of event.removed) {

0 commit comments

Comments
 (0)