5
5
6
6
import { noop } from 'lodash' ;
7
7
import { Uri , Event } from 'vscode' ;
8
- import { BaseLanguageClient } from 'vscode-languageclient' ;
8
+ import { BaseLanguageClient , LanguageClientOptions } from 'vscode-languageclient' ;
9
9
import { LanguageClient } from 'vscode-languageclient/node' ;
10
10
import { PYLANCE_NAME } from './activation/node/languageClientFactory' ;
11
+ import { ILanguageServerOutputChannel } from './activation/types' ;
11
12
import { IExtensionApi } from './apiTypes' ;
12
13
import { isTestExecution , PYTHON_LANGUAGE } from './common/constants' ;
13
14
import { IConfigurationService , Resource } from './common/types' ;
@@ -28,6 +29,8 @@ export function buildApi(
28
29
serviceManager . addSingleton < JupyterExtensionIntegration > ( JupyterExtensionIntegration , JupyterExtensionIntegration ) ;
29
30
const jupyterIntegration = serviceContainer . get < JupyterExtensionIntegration > ( JupyterExtensionIntegration ) ;
30
31
const envService = serviceContainer . get < IEnvironmentVariablesProvider > ( IEnvironmentVariablesProvider ) ;
32
+ const outputChannel = serviceContainer . get < ILanguageServerOutputChannel > ( ILanguageServerOutputChannel ) ;
33
+
31
34
const api : IExtensionApi & {
32
35
/**
33
36
* @deprecated Temporarily exposed for Pylance until we expose this API generally. Will be removed in an
@@ -89,8 +92,14 @@ export function buildApi(
89
92
return envs . PYTHONPATH ;
90
93
} ,
91
94
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
+ } ,
94
103
start : ( client : BaseLanguageClient ) : Promise < void > => client . start ( ) ,
95
104
stop : ( client : BaseLanguageClient ) : Promise < void > => client . stop ( ) ,
96
105
} ,
0 commit comments