mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
Code: reduce progress notification spam
This commit is contained in:
parent
3ab8d7a9ae
commit
5bd84716ed
1 changed files with 8 additions and 6 deletions
|
@ -99,13 +99,15 @@ export async function download(opts: DownloadOpts) {
|
|||
async (progress, _cancellationToken) => {
|
||||
let lastPercentage = 0;
|
||||
await downloadFile(opts.url, tempFile, opts.mode, !!opts.gunzip, (readBytes, totalBytes) => {
|
||||
const newPercentage = (readBytes / totalBytes) * 100;
|
||||
progress.report({
|
||||
message: newPercentage.toFixed(0) + "%",
|
||||
increment: newPercentage - lastPercentage
|
||||
});
|
||||
const newPercentage = Math.round((readBytes / totalBytes) * 100);
|
||||
if (newPercentage !== lastPercentage) {
|
||||
progress.report({
|
||||
message: `${newPercentage.toFixed(0)}%`,
|
||||
increment: newPercentage - lastPercentage
|
||||
});
|
||||
|
||||
lastPercentage = newPercentage;
|
||||
lastPercentage = newPercentage;
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue