@@ -156,14 +156,10 @@ export async function deactivate() {
156
156
ctx = undefined ;
157
157
}
158
158
159
- async function bootstrap ( config : Config , state : PersistentState ) : Promise < string > {
159
+ async function bootstrap ( context : vscode . ExtensionContext , config : Config , state : PersistentState ) : Promise < string > {
160
160
await vscode . workspace . fs . createDirectory ( config . globalStorageUri ) . then ( ) ;
161
- const path = await bootstrapServer ( config , state ) ;
162
- return path ;
163
- }
164
161
165
- async function bootstrapServer ( config : Config , state : PersistentState ) : Promise < string > {
166
- const path = await getServer ( config , state ) ;
162
+ const path = await getServer ( context , config , state ) ;
167
163
if ( ! path ) {
168
164
throw new Error (
169
165
"Rust Analyzer Language Server is not available. " +
@@ -228,7 +224,7 @@ async function patchelf(dest: vscode.Uri): Promise<void> {
228
224
) ;
229
225
}
230
226
231
- async function getServer ( config : Config , state : PersistentState ) : Promise < string | undefined > {
227
+ async function getServer ( context : vscode . ExtensionContext , config : Config , state : PersistentState ) : Promise < string | undefined > {
232
228
const explicitPath = serverPath ( config ) ;
233
229
if ( explicitPath ) {
234
230
if ( explicitPath . startsWith ( "~/" ) ) {
@@ -264,14 +260,14 @@ async function getServer(config: Config, state: PersistentState): Promise<string
264
260
}
265
261
const ext = platform . indexOf ( "-windows-" ) !== - 1 ? ".exe" : "" ;
266
262
const dest = vscode . Uri . joinPath ( config . globalStorageUri , `rust-analyzer-${ platform } ${ ext } ` ) ;
267
- const bundled = vscode . Uri . joinPath ( config . installUri , "server" , `rust-analyzer${ ext } ` ) ;
263
+ const bundled = vscode . Uri . joinPath ( context . extensionUri , "server" , `rust-analyzer${ ext } ` ) ;
268
264
const bundledExists = await vscode . workspace . fs . stat ( bundled ) . then ( ( ) => true , ( ) => false ) ;
269
265
const exists = await vscode . workspace . fs . stat ( dest ) . then ( ( ) => true , ( ) => false ) ;
270
266
if ( bundledExists ) {
271
267
if ( ! await isNixOs ( ) ) {
272
268
return bundled . fsPath ;
273
269
}
274
- if ( ! exists ) {
270
+ if ( ! exists || config . package . version !== state . serverVersion ) {
275
271
await vscode . workspace . fs . copy ( bundled , dest ) ;
276
272
await patchelf ( dest ) ;
277
273
}
0 commit comments