mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 11:38:51 +01:00
JSON Language Server output channel appears twice (#206877)
This commit is contained in:
committed by
GitHub
parent
6c9d5b3df6
commit
8aca9a5331
@@ -6,7 +6,7 @@
|
||||
export type JSONLanguageStatus = { schemas: string[] };
|
||||
|
||||
import {
|
||||
workspace, window, languages, commands, OutputChannel, ExtensionContext, extensions, Uri, ColorInformation,
|
||||
workspace, window, languages, commands, LogOutputChannel, ExtensionContext, extensions, Uri, ColorInformation,
|
||||
Diagnostic, StatusBarAlignment, TextEditor, TextDocument, FormattingOptions, CancellationToken, FoldingRange,
|
||||
ProviderResult, TextEdit, Range, Position, Disposable, CompletionItem, CompletionList, CompletionContext, Hover, MarkdownString, FoldingContext, DocumentSymbol, SymbolInformation, l10n
|
||||
} from 'vscode';
|
||||
@@ -130,6 +130,7 @@ export interface Runtime {
|
||||
readonly timer: {
|
||||
setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): Disposable;
|
||||
};
|
||||
logOutputChannel: LogOutputChannel;
|
||||
}
|
||||
|
||||
export interface SchemaRequestService {
|
||||
@@ -150,12 +151,10 @@ export interface AsyncDisposable {
|
||||
}
|
||||
|
||||
export async function startClient(context: ExtensionContext, newLanguageClient: LanguageClientConstructor, runtime: Runtime): Promise<AsyncDisposable> {
|
||||
const outputChannel = window.createOutputChannel(languageServerDescription);
|
||||
|
||||
const languageParticipants = getLanguageParticipants();
|
||||
context.subscriptions.push(languageParticipants);
|
||||
|
||||
let client: Disposable | undefined = await startClientWithParticipants(context, languageParticipants, newLanguageClient, outputChannel, runtime);
|
||||
let client: Disposable | undefined = await startClientWithParticipants(context, languageParticipants, newLanguageClient, runtime);
|
||||
|
||||
let restartTrigger: Disposable | undefined;
|
||||
languageParticipants.onDidChange(() => {
|
||||
@@ -164,12 +163,12 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
|
||||
}
|
||||
restartTrigger = runtime.timer.setTimeout(async () => {
|
||||
if (client) {
|
||||
outputChannel.appendLine('Extensions have changed, restarting JSON server...');
|
||||
outputChannel.appendLine('');
|
||||
runtime.logOutputChannel.info('Extensions have changed, restarting JSON server...');
|
||||
runtime.logOutputChannel.info('');
|
||||
const oldClient = client;
|
||||
client = undefined;
|
||||
await oldClient.dispose();
|
||||
client = await startClientWithParticipants(context, languageParticipants, newLanguageClient, outputChannel, runtime);
|
||||
client = await startClientWithParticipants(context, languageParticipants, newLanguageClient, runtime);
|
||||
}
|
||||
}, 2000);
|
||||
});
|
||||
@@ -178,12 +177,11 @@ export async function startClient(context: ExtensionContext, newLanguageClient:
|
||||
dispose: async () => {
|
||||
restartTrigger?.dispose();
|
||||
await client?.dispose();
|
||||
outputChannel.dispose();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
async function startClientWithParticipants(context: ExtensionContext, languageParticipants: LanguageParticipants, newLanguageClient: LanguageClientConstructor, outputChannel: OutputChannel, runtime: Runtime): Promise<AsyncDisposable> {
|
||||
async function startClientWithParticipants(context: ExtensionContext, languageParticipants: LanguageParticipants, newLanguageClient: LanguageClientConstructor, runtime: Runtime): Promise<AsyncDisposable> {
|
||||
|
||||
const toDispose: Disposable[] = [];
|
||||
|
||||
@@ -348,7 +346,7 @@ async function startClientWithParticipants(context: ExtensionContext, languagePa
|
||||
}
|
||||
};
|
||||
|
||||
clientOptions.outputChannel = outputChannel;
|
||||
clientOptions.outputChannel = runtime.logOutputChannel;
|
||||
// Create the language client and start the client.
|
||||
const client = newLanguageClient('json', languageServerDescription, clientOptions);
|
||||
client.registerProposedFeatures();
|
||||
|
||||
Reference in New Issue
Block a user