1
- import { spawnSync } from "child_process" ;
2
1
import * as vscode from "vscode" ;
3
2
import * as path from "path" ;
4
3
import { strict as assert } from "assert" ;
5
4
import { promises as fs } from "fs" ;
5
+ import { spawnSync } from "child_process" ;
6
+ import { throttle } from "throttle-debounce" ;
6
7
7
8
import { BinarySource } from "./interfaces" ;
8
9
import { fetchLatestArtifactMetadata } from "./fetch_latest_artifact_metadata" ;
@@ -28,19 +29,23 @@ export async function downloadLatestLanguageServer(
28
29
{
29
30
location : vscode . ProgressLocation . Notification ,
30
31
cancellable : false , // FIXME: add support for canceling download?
31
- title : `Downloading language server ${ releaseName } `
32
+ title : `Downloading language server ( ${ releaseName } ) `
32
33
} ,
33
34
async ( progress , _cancellationToken ) => {
34
35
let lastPrecentage = 0 ;
35
- await downloadFile ( downloadUrl , installationPath , ( readBytes , totalBytes ) => {
36
- const newPercentage = ( readBytes / totalBytes ) * 100 ;
37
- progress . report ( {
38
- message : newPercentage . toFixed ( 0 ) + "%" ,
39
- increment : newPercentage - lastPrecentage
40
- } ) ;
41
-
42
- lastPrecentage = newPercentage ;
43
- } ) ;
36
+ await downloadFile ( downloadUrl , installationPath , throttle (
37
+ 200 ,
38
+ /* noTrailing: */ true ,
39
+ ( readBytes , totalBytes ) => {
40
+ const newPercentage = ( readBytes / totalBytes ) * 100 ;
41
+ progress . report ( {
42
+ message : newPercentage . toFixed ( 0 ) + "%" ,
43
+ increment : newPercentage - lastPrecentage
44
+ } ) ;
45
+
46
+ lastPrecentage = newPercentage ;
47
+ } )
48
+ ) ;
44
49
}
45
50
) ;
46
51
0 commit comments