File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -25,8 +25,9 @@ pub(crate) enum Progress {
2525}
2626
2727impl Progress {
28- pub ( crate ) fn percentage ( done : usize , total : usize ) -> f64 {
29- ( done as f64 / total. max ( 1 ) as f64 ) * 100.0
28+ pub ( crate ) fn fraction ( done : usize , total : usize ) -> f64 {
29+ assert ! ( done <= total) ;
30+ done as f64 / total. max ( 1 ) as f64
3031 }
3132}
3233
@@ -43,11 +44,15 @@ impl GlobalState {
4344 title : & str ,
4445 state : Progress ,
4546 message : Option < String > ,
46- percentage : Option < f64 > ,
47+ fraction : Option < f64 > ,
4748 ) {
4849 if !self . config . client_caps . work_done_progress {
4950 return ;
5051 }
52+ let percentage = fraction. map ( |f| {
53+ assert ! ( 0.0 <= f && f <= 1.0 ) ;
54+ f * 100.0
55+ } ) ;
5156 let token = lsp_types:: ProgressToken :: String ( format ! ( "rustAnalyzer/{}" , title) ) ;
5257 let work_done_progress = match state {
5358 Progress :: Begin => {
Original file line number Diff line number Diff line change @@ -230,7 +230,7 @@ impl GlobalState {
230230 "roots scanned" ,
231231 state,
232232 Some ( format ! ( "{}/{}" , n_done, n_total) ) ,
233- Some ( Progress :: percentage ( n_done, n_total) ) ,
233+ Some ( Progress :: fraction ( n_done, n_total) ) ,
234234 )
235235 }
236236 }
You can’t perform that action at this time.
0 commit comments