@@ -15,6 +15,23 @@ let ctx: Ctx | undefined;
15
15
16
16
const RUST_PROJECT_CONTEXT_NAME = "inRustProject" ;
17
17
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
+
18
35
export interface RustAnalyzerExtensionApi {
19
36
client : lc . LanguageClient ;
20
37
}
@@ -110,7 +127,7 @@ async function initCommonContext(context: vscode.ExtensionContext, ctx: Ctx) {
110
127
// Reloading is inspired by @DanTup maneuver: https://github.com/microsoft/vscode/issues/45774#issuecomment-373423895
111
128
ctx . registerCommand ( "reload" , ( _ ) => async ( ) => {
112
129
void vscode . window . showInformationMessage ( "Reloading rust-analyzer..." ) ;
113
- await deactivate ( ) ;
130
+ await doDeactivate ( ) ;
114
131
while ( context . subscriptions . length > 0 ) {
115
132
try {
116
133
context . subscriptions . pop ( ) ! . dispose ( ) ;
@@ -165,6 +182,14 @@ async function initCommonContext(context: vscode.ExtensionContext, ctx: Ctx) {
165
182
}
166
183
167
184
export 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 ( ) {
168
193
await setContextValue ( RUST_PROJECT_CONTEXT_NAME , undefined ) ;
169
194
await ctx ?. client . stop ( ) ;
170
195
ctx = undefined ;
0 commit comments