55
66import { noop } from 'lodash' ;
77import { Uri , Event } from 'vscode' ;
8- import { BaseLanguageClient } from 'vscode-languageclient' ;
8+ import { BaseLanguageClient , LanguageClientOptions } from 'vscode-languageclient' ;
99import { LanguageClient } from 'vscode-languageclient/node' ;
1010import { PYLANCE_NAME } from './activation/node/languageClientFactory' ;
11+ import { ILanguageServerOutputChannel } from './activation/types' ;
1112import { IExtensionApi } from './apiTypes' ;
1213import { isTestExecution , PYTHON_LANGUAGE } from './common/constants' ;
1314import { IConfigurationService , Resource } from './common/types' ;
@@ -28,6 +29,8 @@ export function buildApi(
2829 serviceManager . addSingleton < JupyterExtensionIntegration > ( JupyterExtensionIntegration , JupyterExtensionIntegration ) ;
2930 const jupyterIntegration = serviceContainer . get < JupyterExtensionIntegration > ( JupyterExtensionIntegration ) ;
3031 const envService = serviceContainer . get < IEnvironmentVariablesProvider > ( IEnvironmentVariablesProvider ) ;
32+ const outputChannel = serviceContainer . get < ILanguageServerOutputChannel > ( ILanguageServerOutputChannel ) ;
33+
3134 const api : IExtensionApi & {
3235 /**
3336 * @deprecated Temporarily exposed for Pylance until we expose this API generally. Will be removed in an
@@ -89,8 +92,14 @@ export function buildApi(
8992 return envs . PYTHONPATH ;
9093 } ,
9194 onDidEnvironmentVariablesChange : envService . onDidEnvironmentVariablesChange ,
92- createClient : ( ...args : any [ ] ) : BaseLanguageClient =>
93- new LanguageClient ( PYTHON_LANGUAGE , PYLANCE_NAME , args [ 0 ] , args [ 1 ] ) ,
95+ createClient : ( ...args : any [ ] ) : BaseLanguageClient => {
96+ // Make sure we share output channel so that we can share one with
97+ // Jedi as well.
98+ const clientOptions = args [ 1 ] as LanguageClientOptions ;
99+ clientOptions . outputChannel = clientOptions . outputChannel ?? outputChannel . channel ;
100+
101+ return new LanguageClient ( PYTHON_LANGUAGE , PYLANCE_NAME , args [ 0 ] , clientOptions ) ;
102+ } ,
94103 start : ( client : BaseLanguageClient ) : Promise < void > => client . start ( ) ,
95104 stop : ( client : BaseLanguageClient ) : Promise < void > => client . stop ( ) ,
96105 } ,
0 commit comments