Skip to content

Commit b6afc05

Browse files
committed
修复使用命令重启服务器后会创建额外的输出通道的问题
1 parent 497aa59 commit b6afc05

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

client/src/languageserver.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
} from 'vscode-languageclient/node';
2424

2525
export let defaultClient: LuaClient | null;
26+
let outputChannel: vscode.OutputChannel | undefined;
2627

2728
function registerCustomCommands(context: ExtensionContext) {
2829
context.subscriptions.push(Commands.registerCommand('lua.config', (changes) => {
@@ -137,6 +138,11 @@ class LuaClient extends Disposable {
137138
}
138139

139140
async start() {
141+
// 复用或创建输出通道
142+
if (!outputChannel) {
143+
outputChannel = vscode.window.createOutputChannel("Lua", { log: true });
144+
}
145+
140146
// Options to control the language client
141147
const clientOptions: LanguageClientOptions = {
142148
// Register the server for plain text documents
@@ -146,6 +152,7 @@ class LuaClient extends Disposable {
146152
isTrusted: true,
147153
supportHtml: true,
148154
},
155+
outputChannel: outputChannel,
149156
initializationOptions: {
150157
changeConfiguration: true,
151158
statusBar: true,
@@ -446,6 +453,11 @@ export async function deactivate() {
446453
defaultClient.dispose();
447454
defaultClient = null;
448455
}
456+
// 清理输出通道
457+
if (outputChannel) {
458+
outputChannel.dispose();
459+
outputChannel = undefined;
460+
}
449461
return undefined;
450462
}
451463
vscode.SyntaxTokenType.String

0 commit comments

Comments
 (0)