Skip to content

Commit e56df9a

Browse files
committed
同一个目录下的独立文件共享一个语言服务
1 parent cc4b8ce commit e56df9a

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

client/out/languageserver.js

Lines changed: 5 additions & 4 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: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +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())) {
174+
let parentUri = Uri.file(path.parse(uri.fsPath).dir)
175+
if (!clients.has(parentUri.toString())) {
175176
let client = start(context, [
176-
{ scheme: 'file', language: 'lua', pattern: `${uri.fsPath}` }
177+
{ scheme: 'file', language: 'lua', pattern: `${parentUri.fsPath}/**/*` }
177178
], null);
178-
clients.set(uri.toString(), client);
179+
clients.set(parentUri.toString(), client);
179180
}
180181
return;
181182
}
@@ -202,7 +203,7 @@ export function activate(context: ExtensionContext) {
202203
}
203204

204205
Workspace.onDidOpenTextDocument(didOpenTextDocument);
205-
Workspace.onDidCloseTextDocument(didCloseTextDocument);
206+
//Workspace.onDidCloseTextDocument(didCloseTextDocument);
206207
Workspace.textDocuments.forEach(didOpenTextDocument);
207208
Workspace.onDidChangeWorkspaceFolders((event) => {
208209
for (let folder of event.removed) {

0 commit comments

Comments
 (0)