File tree 4 files changed +26
-2
lines changed
4 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 60
60
" onCommand:rust-analyzer.analyzerStatus" ,
61
61
" onCommand:rust-analyzer.memoryUsage" ,
62
62
" onCommand:rust-analyzer.reloadWorkspace" ,
63
+ " onCommand:rust-analyzer.startServer" ,
63
64
" workspaceContains:*/Cargo.toml" ,
64
65
" workspaceContains:*/rust-project.json"
65
66
],
191
192
"title" : " Restart server" ,
192
193
"category" : " rust-analyzer"
193
194
},
195
+ {
196
+ "command" : " rust-analyzer.startServer" ,
197
+ "title" : " Start server" ,
198
+ "category" : " rust-analyzer"
199
+ },
200
+ {
201
+ "command" : " rust-analyzer.stopServer" ,
202
+ "title" : " Stop server" ,
203
+ "category" : " rust-analyzer"
204
+ },
194
205
{
195
206
"command" : " rust-analyzer.onEnter" ,
196
207
"title" : " Enhanced enter key" ,
Original file line number Diff line number Diff line change @@ -76,6 +76,14 @@ export async function createClient(
76
76
outputChannel,
77
77
middleware : {
78
78
workspace : {
79
+ // HACK: This is a workaround, when the client has been disposed, VSCode
80
+ // continues to emit events to the client and the default one for this event
81
+ // attempt to restart the client for no reason
82
+ async didChangeWatchedFile ( event , next ) {
83
+ if ( client . isRunning ( ) ) {
84
+ await next ( event ) ;
85
+ }
86
+ } ,
79
87
async configuration (
80
88
params : lc . ConfigurationParams ,
81
89
token : vscode . CancellationToken ,
Original file line number Diff line number Diff line change @@ -68,8 +68,6 @@ export class Ctx {
68
68
}
69
69
70
70
if ( ! this . client ) {
71
- log . info ( "Creating language client" ) ;
72
-
73
71
this . _serverPath = await bootstrap ( this . extCtx , this . config , this . state ) . catch (
74
72
( err ) => {
75
73
let message = "bootstrap error. " ;
Original file line number Diff line number Diff line change @@ -126,6 +126,13 @@ async function initCommonContext(ctx: Ctx) {
126
126
await ctx . activate ( ) ;
127
127
} ) ;
128
128
129
+ ctx . registerCommand ( "startServer" , ( _ ) => async ( ) => {
130
+ await ctx . activate ( ) ;
131
+ } ) ;
132
+ ctx . registerCommand ( "stopServer" , ( _ ) => async ( ) => {
133
+ // FIXME: We should re-use the client, that is ctx.deactivate() if none of the configs have changed
134
+ await ctx . disposeClient ( ) ;
135
+ } ) ;
129
136
ctx . registerCommand ( "analyzerStatus" , commands . analyzerStatus ) ;
130
137
ctx . registerCommand ( "memoryUsage" , commands . memoryUsage ) ;
131
138
ctx . registerCommand ( "shuffleCrateGraph" , commands . shuffleCrateGraph ) ;
You can’t perform that action at this time.
0 commit comments