@@ -14,7 +14,6 @@ import { isImplicitProjectConfigFile, openOrCreateConfig, openProjectConfigForFi
14
14
15
15
const localize = nls . loadMessageBundle ( ) ;
16
16
17
-
18
17
namespace IntellisenseState {
19
18
export const enum Type { None , Pending , Resolved , SyntaxOnly }
20
19
@@ -51,7 +50,7 @@ export class IntellisenseStatus extends Disposable {
51
50
public readonly openOpenConfigCommandId = '_typescript.openConfig' ;
52
51
public readonly createConfigCommandId = '_typescript.createConfig' ;
53
52
54
- private readonly _statusItem : vscode . LanguageStatusItem ;
53
+ private _statusItem ? : vscode . LanguageStatusItem ;
55
54
56
55
private _ready = false ;
57
56
private _state : IntellisenseState . State = IntellisenseState . None ;
@@ -63,9 +62,6 @@ export class IntellisenseStatus extends Disposable {
63
62
) {
64
63
super ( ) ;
65
64
66
- this . _statusItem = this . _register ( vscode . languages . createLanguageStatusItem ( 'typescript.projectStatus' , jsTsLanguageModes ) ) ;
67
- this . _statusItem . name = localize ( 'statusItem.name' , "JS/TS IntelliSense Status" ) ;
68
-
69
65
commandManager . register ( {
70
66
id : this . openOpenConfigCommandId ,
71
67
execute : async ( rootPath : string , projectType : ProjectType ) => {
@@ -91,6 +87,11 @@ export class IntellisenseStatus extends Disposable {
91
87
} ) ;
92
88
}
93
89
90
+ override dispose ( ) {
91
+ super . dispose ( ) ;
92
+ this . _statusItem ?. dispose ( ) ;
93
+ }
94
+
94
95
private async updateStatus ( ) {
95
96
const doc = this . _activeTextEditorManager . activeJsTsEditor ?. document ;
96
97
if ( ! doc || ! isSupportedLanguageMode ( doc ) ) {
@@ -140,55 +141,77 @@ export class IntellisenseStatus extends Disposable {
140
141
141
142
switch ( this . _state . type ) {
142
143
case IntellisenseState . Type . None :
144
+ this . _statusItem ?. dispose ( ) ;
145
+ this . _statusItem = undefined ;
143
146
break ;
144
147
145
148
case IntellisenseState . Type . Pending :
146
- this . _statusItem . text = '$(loading~spin)' ;
147
- this . _statusItem . detail = localize ( 'pending.detail' , 'Loading IntelliSense status' ) ;
148
- this . _statusItem . command = undefined ;
149
- break ;
149
+ {
150
+ const statusItem = this . ensureStatusItem ( ) ;
151
+ statusItem . severity = vscode . LanguageStatusSeverity . Information ;
152
+ statusItem . text = '$(loading~spin)' ;
153
+ statusItem . detail = localize ( 'pending.detail' , 'Loading IntelliSense status' ) ;
154
+ statusItem . command = undefined ;
155
+ break ;
156
+ }
150
157
151
158
case IntellisenseState . Type . Resolved :
152
- const rootPath = this . _client . getWorkspaceRootForResource ( this . _state . resource ) ;
153
- if ( ! rootPath ) {
154
- return ;
159
+ {
160
+ const rootPath = this . _client . getWorkspaceRootForResource ( this . _state . resource ) ;
161
+ if ( ! rootPath ) {
162
+ return ;
163
+ }
164
+
165
+ const statusItem = this . ensureStatusItem ( ) ;
166
+ statusItem . severity = vscode . LanguageStatusSeverity . Information ;
167
+ if ( isImplicitProjectConfigFile ( this . _state . configFile ) ) {
168
+ statusItem . text = this . _state . projectType === ProjectType . TypeScript
169
+ ? localize ( 'resolved.detail.noTsConfig' , "No tsconfig" )
170
+ : localize ( 'resolved.detail.noJsConfig' , "No jsconfig" ) ;
171
+
172
+ statusItem . detail = undefined ;
173
+ statusItem . command = {
174
+ command : this . createConfigCommandId ,
175
+ title : this . _state . projectType === ProjectType . TypeScript
176
+ ? localize ( 'resolved.command.title.createTsconfig' , "Create tsconfig" )
177
+ : localize ( 'resolved.command.title.createJsconfig' , "Create jsconfig" ) ,
178
+ arguments : [ rootPath ] ,
179
+ } ;
180
+ } else {
181
+ statusItem . text = vscode . workspace . asRelativePath ( this . _state . configFile ) ;
182
+ statusItem . detail = undefined ;
183
+ statusItem . command = {
184
+ command : this . openOpenConfigCommandId ,
185
+ title : localize ( 'resolved.command.title.open' , "Open config file" ) ,
186
+ arguments : [ rootPath ] ,
187
+ } ;
188
+ }
155
189
}
190
+ break ;
156
191
157
- if ( isImplicitProjectConfigFile ( this . _state . configFile ) ) {
158
- this . _statusItem . text = this . _state . projectType === ProjectType . TypeScript
159
- ? localize ( 'resolved.detail.noTsConfig' , "No tsconfig" )
160
- : localize ( 'resolved.detail.noJsConfig' , "No jsconfig" ) ;
161
-
162
- this . _statusItem . detail = undefined ;
163
- this . _statusItem . command = {
164
- command : this . createConfigCommandId ,
165
- title : this . _state . projectType === ProjectType . TypeScript
166
- ? localize ( 'resolved.command.title.createTsconfig' , "Create tsconfig" )
167
- : localize ( 'resolved.command.title.createJsconfig' , "Create jsconfig" ) ,
168
- arguments : [ rootPath ] ,
169
- } ;
170
- } else {
171
- this . _statusItem . text = vscode . workspace . asRelativePath ( this . _state . configFile ) ;
172
- this . _statusItem . detail = undefined ;
173
- this . _statusItem . command = {
174
- command : this . openOpenConfigCommandId ,
175
- title : localize ( 'resolved.command.title.open' , "Open config file" ) ,
176
- arguments : [ rootPath ] ,
192
+ case IntellisenseState . Type . SyntaxOnly :
193
+ {
194
+ const statusItem = this . ensureStatusItem ( ) ;
195
+ statusItem . severity = vscode . LanguageStatusSeverity . Warning ;
196
+ statusItem . text = localize ( 'syntaxOnly.text' , 'Partial Mode' ) ;
197
+ statusItem . detail = localize ( 'syntaxOnly.detail' , 'Project Wide IntelliSense not available' ) ;
198
+ statusItem . command = {
199
+ title : localize ( 'syntaxOnly.command.title.learnMore' , "Learn More" ) ,
200
+ command : 'vscode.open' ,
201
+ arguments : [
202
+ vscode . Uri . parse ( 'https://aka.ms/vscode/jsts/partial-mode' ) ,
203
+ ]
177
204
} ;
205
+ break ;
178
206
}
179
- break ;
207
+ }
208
+ }
180
209
181
- case IntellisenseState . Type . SyntaxOnly :
182
- this . _statusItem . text = localize ( 'syntaxOnly.text' , 'Partial Mode' ) ;
183
- this . _statusItem . detail = localize ( 'syntaxOnly.detail' , 'Project Wide IntelliSense not available' ) ;
184
- this . _statusItem . command = {
185
- title : localize ( 'syntaxOnly.command.title.learnMore' , "Learn More" ) ,
186
- command : 'vscode.open' ,
187
- arguments : [
188
- vscode . Uri . parse ( 'https://aka.ms/vscode/jsts/partial-mode' ) ,
189
- ]
190
- } ;
191
- break ;
210
+ private ensureStatusItem ( ) : vscode . LanguageStatusItem {
211
+ if ( ! this . _statusItem ) {
212
+ this . _statusItem = vscode . languages . createLanguageStatusItem ( 'typescript.projectStatus' , jsTsLanguageModes ) ;
213
+ this . _statusItem . name = localize ( 'statusItem.name' , "JS/TS IntelliSense Status" ) ;
192
214
}
215
+ return this . _statusItem ;
193
216
}
194
217
}
0 commit comments