Skip to content

Commit 7da6ad0

Browse files
authored
Fix sourcekit-lsp diagnostics counter (#1834)
* Fix sourcekit diagnostics counter * Update changelog
1 parent aadc926 commit 7da6ad0

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- Improve error handling when the swift path is misconfigured ([#1801](https://github.com/swiftlang/vscode-swift/pull/1801))
1616
- Fix an error when performing "Run/Debug Tests Multiple Times" on Linux ([#1824](https://github.com/swiftlang/vscode-swift/pull/1824))
1717
- Fix the `> Swift: Run Swift Script` command not running unless a Swift Package folder is open ([#1832](https://github.com/swiftlang/vscode-swift/pull/1832))
18+
- Fix the SourceKit-LSP diagnostics reported progress ([#1799](https://github.com/swiftlang/vscode-swift/pull/1799))
1819

1920
## 2.11.20250806 - 2025-08-06
2021

src/commands/captureDiagnostics.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,15 @@ async function sourcekitDiagnose(ctx: FolderContext, dir: string) {
332332
},
333333
async progress => {
334334
progress.report({ message: "Diagnosing SourceKit-LSP..." });
335-
const writableStream = progressUpdatingWritable(percent =>
336-
progress.report({ message: `Diagnosing SourceKit-LSP: ${percent}%` })
337-
);
335+
let lastProgress = 0;
336+
const writableStream = progressUpdatingWritable(percentStr => {
337+
const percent = parseInt(percentStr, 10);
338+
progress.report({
339+
message: `Diagnosing SourceKit-LSP: ${percent}%`,
340+
increment: percent - lastProgress,
341+
});
342+
lastProgress = percent;
343+
});
338344

339345
await execFileStreamOutput(
340346
serverPath,
@@ -362,7 +368,7 @@ function progressUpdatingWritable(updateProgress: (str: string) => void): Writab
362368
return new Writable({
363369
write(chunk, _encoding, callback) {
364370
const str = (chunk as Buffer).toString("utf8").trim();
365-
const percent = /^([0-9])+%/.exec(str);
371+
const percent = /^([0-9]+)%/.exec(str);
366372
if (percent && percent[1]) {
367373
updateProgress(percent[1]);
368374
}

0 commit comments

Comments
 (0)