Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@
void
>("powerShell/getVersion");

const DidOpenTextDocumentNotificationType = new NotificationType<{
textDocument: {
uri: string;
languageId: string;
version: number;
text: string;
};
}>("textDocument/didOpen");

const DidCloseTextDocumentNotificationType = new NotificationType<{
textDocument: {
uri: string;
};
}>("textDocument/didClose");

export class SessionManager implements Middleware {
public HostName: string;
public DisplayName: string;
Expand Down Expand Up @@ -295,6 +310,7 @@
`Started PowerShell v${this.versionDetails.version}.`,
);
this.setSessionRunningStatus(); // Yay, we made it!
this.refreshOpenPowerShellDocumentDiagnostics();

await this.writePidIfInDevMode(this.languageServerProcess);

Expand Down Expand Up @@ -1167,6 +1183,49 @@
}
}

private refreshOpenPowerShellDocumentDiagnostics(): void {
if (!this.languageClient?.isRunning()) {
return;
}

const openPowerShellDocuments = vscode.workspace.textDocuments.filter(
(document) =>
document.languageId === "powershell" &&
(document.uri.scheme === "file" ||
document.uri.scheme === "untitled"),
);

if (openPowerShellDocuments.length === 0) {
return;
}

this.logger.writeDebug(
`Refreshing analysis for ${openPowerShellDocuments.length} open PowerShell document(s).`,
);

for (const document of openPowerShellDocuments) {
const uri = document.uri.toString();
this.languageClient.sendNotification(

Check failure on line 1208 in src/session.ts

View workflow job for this annotation

GitHub Actions / node (ubuntu-latest)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator

Check failure on line 1208 in src/session.ts

View workflow job for this annotation

GitHub Actions / node (macos-latest)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
DidCloseTextDocumentNotificationType,
{
textDocument: { uri },
},
);

this.languageClient.sendNotification(

Check failure on line 1215 in src/session.ts

View workflow job for this annotation

GitHub Actions / node (ubuntu-latest)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator

Check failure on line 1215 in src/session.ts

View workflow job for this annotation

GitHub Actions / node (macos-latest)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
DidOpenTextDocumentNotificationType,
{
textDocument: {
uri,
languageId: document.languageId,
version: document.version,
text: document.getText(),
},
},
);
}
}

private createStatusBarItem(): vscode.LanguageStatusItem {
const statusTitle = "Show PowerShell Session Menu";
const languageStatusItem = vscode.languages.createLanguageStatusItem(
Expand Down
Loading