1
1
import * as os from "os" ;
2
2
import * as vscode from 'vscode' ;
3
3
import { ArtifactSource } from "./installation/interfaces" ;
4
- import { log } from "./util" ;
4
+ import { log , vscodeReloadWindow } from "./util" ;
5
5
6
6
const RA_LSP_DEBUG = process . env . __RA_LSP_SERVER_DEBUG ;
7
7
@@ -43,20 +43,20 @@ export class Config {
43
43
]
44
44
. map ( opt => `${ this . rootSection } .${ opt } ` ) ;
45
45
46
+ readonly packageJsonVersion = vscode
47
+ . extensions
48
+ . getExtension ( this . extensionId ) !
49
+ . packageJSON
50
+ . version as string ; // n.n.YYYYMMDD[-nightly]
51
+
46
52
/**
47
53
* Either `nightly` or `YYYY-MM-DD` (i.e. `stable` release)
48
54
*/
49
55
readonly extensionReleaseTag : string = ( ( ) => {
50
- const packageJsonVersion = vscode
51
- . extensions
52
- . getExtension ( this . extensionId ) !
53
- . packageJSON
54
- . version as string ; // n.n.YYYYMMDD[-nightly]
55
-
56
- if ( packageJsonVersion . endsWith ( NIGHTLY_TAG ) ) return NIGHTLY_TAG ;
56
+ if ( this . packageJsonVersion . endsWith ( NIGHTLY_TAG ) ) return NIGHTLY_TAG ;
57
57
58
58
const realVersionRegexp = / ^ \d + \. \d + \. ( \d { 4 } ) ( \d { 2 } ) ( \d { 2 } ) / ;
59
- const [ , yyyy , mm , dd ] = packageJsonVersion . match ( realVersionRegexp ) ! ;
59
+ const [ , yyyy , mm , dd ] = this . packageJsonVersion . match ( realVersionRegexp ) ! ;
60
60
61
61
return `${ yyyy } -${ mm } -${ dd } ` ;
62
62
} ) ( ) ;
@@ -72,7 +72,10 @@ export class Config {
72
72
this . cfg = vscode . workspace . getConfiguration ( this . rootSection ) ;
73
73
const enableLogging = this . cfg . get ( "trace.extension" ) as boolean ;
74
74
log . setEnabled ( enableLogging ) ;
75
- log . debug ( "Using configuration:" , this . cfg ) ;
75
+ log . debug (
76
+ "Extension version:" , this . packageJsonVersion ,
77
+ "using configuration:" , this . cfg
78
+ ) ;
76
79
}
77
80
78
81
private async onConfigChange ( event : vscode . ConfigurationChangeEvent ) {
@@ -90,7 +93,7 @@ export class Config {
90
93
) ;
91
94
92
95
if ( userResponse === "Reload now" ) {
93
- vscode . commands . executeCommand ( "workbench.action.reloadWindow" ) ;
96
+ await vscodeReloadWindow ( ) ;
94
97
}
95
98
}
96
99
@@ -180,16 +183,11 @@ export class Config {
180
183
}
181
184
182
185
readonly installedNightlyExtensionReleaseDate = new DateStorage (
183
- "rust-analyzer- installed-nightly-extension-release-date" ,
186
+ "installed-nightly-extension-release-date" ,
184
187
this . ctx . globalState
185
188
) ;
186
- readonly serverReleaseDate = new DateStorage (
187
- "rust-analyzer-server-release-date" ,
188
- this . ctx . globalState
189
- ) ;
190
- readonly serverReleaseTag = new Storage < null | string > (
191
- "rust-analyzer-release-tag" , this . ctx . globalState , null
192
- ) ;
189
+ readonly serverReleaseDate = new DateStorage ( "server-release-date" , this . ctx . globalState ) ;
190
+ readonly serverReleaseTag = new Storage < null | string > ( "server-release-tag" , this . ctx . globalState , null ) ;
193
191
194
192
// We don't do runtime config validation here for simplicity. More on stackoverflow:
195
193
// https://stackoverflow.com/questions/60135780/what-is-the-best-way-to-type-check-the-configuration-for-vscode-extension
0 commit comments