@@ -15,6 +15,23 @@ let ctx: Ctx | undefined;
1515
1616const RUST_PROJECT_CONTEXT_NAME = "inRustProject" ;
1717
18+ let TRACE_OUTPUT_CHANNEL : vscode . OutputChannel | null = null ;
19+ export function traceOutputChannel ( ) {
20+ if ( ! TRACE_OUTPUT_CHANNEL ) {
21+ TRACE_OUTPUT_CHANNEL = vscode . window . createOutputChannel (
22+ "Rust Analyzer Language Server Trace"
23+ ) ;
24+ }
25+ return TRACE_OUTPUT_CHANNEL ;
26+ }
27+ let OUTPUT_CHANNEL : vscode . OutputChannel | null = null ;
28+ export function outputChannel ( ) {
29+ if ( ! OUTPUT_CHANNEL ) {
30+ OUTPUT_CHANNEL = vscode . window . createOutputChannel ( "Rust Analyzer Language Server" ) ;
31+ }
32+ return OUTPUT_CHANNEL ;
33+ }
34+
1835export interface RustAnalyzerExtensionApi {
1936 client : lc . LanguageClient ;
2037}
@@ -110,7 +127,7 @@ async function initCommonContext(context: vscode.ExtensionContext, ctx: Ctx) {
110127 // Reloading is inspired by @DanTup maneuver: https://github.com/microsoft/vscode/issues/45774#issuecomment-373423895
111128 ctx . registerCommand ( "reload" , ( _ ) => async ( ) => {
112129 void vscode . window . showInformationMessage ( "Reloading rust-analyzer..." ) ;
113- await deactivate ( ) ;
130+ await doDeactivate ( ) ;
114131 while ( context . subscriptions . length > 0 ) {
115132 try {
116133 context . subscriptions . pop ( ) ! . dispose ( ) ;
@@ -165,6 +182,14 @@ async function initCommonContext(context: vscode.ExtensionContext, ctx: Ctx) {
165182}
166183
167184export async function deactivate ( ) {
185+ TRACE_OUTPUT_CHANNEL ?. dispose ( ) ;
186+ TRACE_OUTPUT_CHANNEL = null ;
187+ OUTPUT_CHANNEL ?. dispose ( ) ;
188+ OUTPUT_CHANNEL = null ;
189+ await doDeactivate ( ) ;
190+ }
191+
192+ async function doDeactivate ( ) {
168193 await setContextValue ( RUST_PROJECT_CONTEXT_NAME , undefined ) ;
169194 await ctx ?. client . stop ( ) ;
170195 ctx = undefined ;
0 commit comments