File tree 4 files changed +29
-3
lines changed
4 files changed +29
-3
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 @@ -61,13 +61,14 @@ function renderHoverActions(actions: ra.CommandLinkGroup[]): vscode.MarkdownStri
61
61
result . isTrusted = true ;
62
62
return result ;
63
63
}
64
-
64
+ let x = 0 ;
65
65
export async function createClient (
66
66
traceOutputChannel : vscode . OutputChannel ,
67
67
outputChannel : vscode . OutputChannel ,
68
68
initializationOptions : vscode . WorkspaceConfiguration ,
69
69
serverOptions : lc . ServerOptions
70
70
) : Promise < lc . LanguageClient > {
71
+ const X = x ++ ;
71
72
const clientOptions : lc . LanguageClientOptions = {
72
73
documentSelector : [ { scheme : "file" , language : "rust" } ] ,
73
74
initializationOptions,
@@ -76,6 +77,15 @@ export async function createClient(
76
77
outputChannel,
77
78
middleware : {
78
79
workspace : {
80
+ async didChangeWatchedFile ( event , next ) {
81
+ console . log ( X ) ;
82
+ console . log ( client ) ;
83
+ if ( client . isRunning ( ) ) {
84
+ // HACK: This is a workaround, when the client has been disposed, VSCode
85
+ // continues to emit this event to the client...
86
+ await next ( event ) ;
87
+ }
88
+ } ,
79
89
async configuration (
80
90
params : lc . ConfigurationParams ,
81
91
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