diff options
| author | Laurențiu Nicola <lnicola@dend.ro> | 2021-01-24 16:13:33 +0200 |
|---|---|---|
| committer | Laurențiu Nicola <lnicola@dend.ro> | 2021-01-25 10:05:38 +0200 |
| commit | 5bd84716ed6efe41a183c4ae3db364e2c49fa9cb (patch) | |
| tree | cf15a498d09dca9ec7d05c499bea67bf23e1c092 /editors/code/src | |
| parent | 3ab8d7a9ae1b8c5e421a4666f6693ae7278a7a3c (diff) | |
| download | rust-5bd84716ed6efe41a183c4ae3db364e2c49fa9cb.tar.gz rust-5bd84716ed6efe41a183c4ae3db364e2c49fa9cb.zip | |
Code: reduce progress notification spam
Diffstat (limited to 'editors/code/src')
| -rw-r--r-- | editors/code/src/net.ts | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/editors/code/src/net.ts b/editors/code/src/net.ts index 1ab21e7262d..3e50d352c90 100644 --- a/editors/code/src/net.ts +++ b/editors/code/src/net.ts @@ -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 - }); - - lastPercentage = newPercentage; + const newPercentage = Math.round((readBytes / totalBytes) * 100); + if (newPercentage !== lastPercentage) { + progress.report({ + message: `${newPercentage.toFixed(0)}%`, + increment: newPercentage - lastPercentage + }); + + lastPercentage = newPercentage; + } }); } ); |
