Skip to content

Commit 73201bb

Browse files
author
Kapil Borle
committed
Add inline documentation to DocumentFormatter.ts
1 parent ed9451a commit 73201bb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/features/DocumentFormatter.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,23 @@ class PSDocumentFormattingEditProvider implements DocumentFormattingEditProvider
120120

121121
let editor: TextEditor = this.getEditor(document);
122122
if (editor === undefined) {
123-
Window.showWarningMessage(`Something went wrong. Cannot format ${path.basename(document.fileName)}`);
124123
return this.emptyPromise;
125124
}
126125

126+
// Check if the document is already being formatted.
127+
// If so, then ignore the formatting request.
127128
if (this.isDocumentLocked(document)) {
128-
Window.showWarningMessage(`Formatting ${path.basename(document.fileName)}. Please wait.`);
129129
return this.emptyPromise;
130130
}
131131

132132
this.lockDocument(document);
133133
let textEdits: Thenable<TextEdit[]> = this.executeRulesInOrder(editor, range, options, 0);
134+
135+
// If the session crashes for any reason during formatting
136+
// then the document won't be released and hence we won't
137+
// be able to format it after restarting the session.
138+
// Similar issue with the status - the bar will keep displaying
139+
// the previous status even after restarting the session.
134140
this.releaseDocument(document, textEdits);
135141
AnimatedStatusBar.showAnimatedStatusBarMessage("Formatting PowerShell document", textEdits);
136142
return textEdits;

0 commit comments

Comments
 (0)