@@ -180,28 +180,33 @@ class PSDocumentFormattingEditProvider implements DocumentFormattingEditProvider
180
180
181
181
let textEdits : Thenable < TextEdit [ ] > = this . executeRulesInOrder ( editor , range , options , 0 ) ;
182
182
this . lockDocument ( document , textEdits ) ;
183
-
184
- // FIXME If the session crashes for any reason during formatting
185
- // then the bar will keep displaying the previous status even after restarting the session.
186
- // A fix is to restart the window
187
- // AnimatedStatusBar.showAnimatedStatusBarMessage("Formatting PowerShell document", textEdits);
188
183
PSDocumentFormattingEditProvider . showStatusBar ( document , textEdits ) ;
189
184
return textEdits ;
190
185
}
191
186
192
- getEditor ( document : TextDocument ) : TextEditor {
187
+ setLanguageClient ( languageClient : LanguageClient ) : void {
188
+ this . languageClient = languageClient ;
189
+
190
+ // setLanguageClient is called while restarting a session,
191
+ // so this makes sure we clean up the document locker and
192
+ // any residual status bars
193
+ PSDocumentFormattingEditProvider . documentLocker . unlockAll ( ) ;
194
+ PSDocumentFormattingEditProvider . disposeAllStatusBars ( ) ;
195
+ }
196
+
197
+ private getEditor ( document : TextDocument ) : TextEditor {
193
198
return Window . visibleTextEditors . find ( ( e , n , obj ) => { return e . document === document ; } ) ;
194
199
}
195
200
196
- isDocumentLocked ( document : TextDocument ) : boolean {
201
+ private isDocumentLocked ( document : TextDocument ) : boolean {
197
202
return PSDocumentFormattingEditProvider . documentLocker . isLocked ( document ) ;
198
203
}
199
204
200
- lockDocument ( document : TextDocument , unlockWhenDone : Thenable < any > ) : void {
205
+ private lockDocument ( document : TextDocument , unlockWhenDone : Thenable < any > ) : void {
201
206
PSDocumentFormattingEditProvider . documentLocker . lock ( document , unlockWhenDone ) ;
202
207
}
203
208
204
- executeRulesInOrder (
209
+ private executeRulesInOrder (
205
210
editor : TextEditor ,
206
211
range : Range ,
207
212
options : FormattingOptions ,
@@ -267,7 +272,7 @@ class PSDocumentFormattingEditProvider implements DocumentFormattingEditProvider
267
272
}
268
273
}
269
274
270
- applyEdit (
275
+ private applyEdit (
271
276
editor : TextEditor ,
272
277
edits : ScriptRegion [ ] ,
273
278
range : Range ,
@@ -303,7 +308,7 @@ class PSDocumentFormattingEditProvider implements DocumentFormattingEditProvider
303
308
}
304
309
}
305
310
306
- getSelectionRange ( document : TextDocument ) : Range {
311
+ private getSelectionRange ( document : TextDocument ) : Range {
307
312
let editor = vscode . window . visibleTextEditors . find ( editor => editor . document === document ) ;
308
313
if ( editor !== undefined ) {
309
314
return editor . selection as Range ;
@@ -312,17 +317,7 @@ class PSDocumentFormattingEditProvider implements DocumentFormattingEditProvider
312
317
return null ;
313
318
}
314
319
315
- setLanguageClient ( languageClient : LanguageClient ) : void {
316
- this . languageClient = languageClient ;
317
-
318
- // setLanguageClient is called while restarting a session,
319
- // so this makes sure we clean up the document locker and
320
- // any residual status bars
321
- PSDocumentFormattingEditProvider . documentLocker . unlockAll ( ) ;
322
- PSDocumentFormattingEditProvider . disposeAllStatusBars ( ) ;
323
- }
324
-
325
- getSettings ( rule : string ) : any {
320
+ private getSettings ( rule : string ) : any {
326
321
let psSettings : Settings . ISettings = Settings . load ( Utils . PowerShellLanguageId ) ;
327
322
let ruleSettings = new Object ( ) ;
328
323
ruleSettings [ "Enable" ] = true ;
@@ -364,8 +359,6 @@ class PSDocumentFormattingEditProvider implements DocumentFormattingEditProvider
364
359
private static disposeAllStatusBars ( ) {
365
360
Object . keys ( this . statusBarTracker ) . slice ( ) . forEach ( ( key ) => this . disposeStatusBar ( key ) ) ;
366
361
}
367
-
368
-
369
362
}
370
363
371
364
export class DocumentFormatterFeature implements IFeature {
0 commit comments