Skip to content

Commit 60979e2

Browse files
committed
Prompt for diagnostics at most once an hour
1 parent 7d21e9f commit 60979e2

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/sourcekit-lsp/LanguageClientManager.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,12 +541,17 @@ export class LanguageClientManager {
541541
);
542542
},
543543
handleWorkDoneProgress: (() => {
544-
let hasPrompted = false;
544+
let lastPrompted = new Date(0).getTime();
545545
return async (token, params, next) => {
546546
const result = await next(token, params);
547-
if (!hasPrompted && token.toString().startsWith("sourcekitd-crashed")) {
548-
// Only prompt once in case sourcekit is in a crash loop
549-
hasPrompted = true;
547+
const now = new Date().getTime();
548+
const oneHour = 60 * 60 * 1000;
549+
if (
550+
now - lastPrompted > oneHour &&
551+
token.toString().startsWith("sourcekitd-crashed")
552+
) {
553+
// Only prompt once an hour in case sourcekit is in a crash loop
554+
lastPrompted = now;
550555
promptForDiagnostics(this.workspaceContext);
551556
}
552557
return result;

0 commit comments

Comments
 (0)