Skip to content

Commit 5438d82

Browse files
authored
Fix RMD Progress Bar (#1491)
RMD progress bar now respects chunk progress reported in the form of x/y
1 parent 26d72d0 commit 5438d82

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/rmarkdown/manager.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ export abstract class RMarkdownManager {
123123

124124
}
125125
const percentRegex = /[0-9]+(?=%)/g;
126+
const divisionRegex = /([0-9]+)\/([0-9]+)/g;
126127
const percentRegOutput = dat.match(percentRegex);
127-
128128
if (percentRegOutput) {
129129
for (const item of percentRegOutput) {
130130
const perc = Number(item);
@@ -136,7 +136,20 @@ export abstract class RMarkdownManager {
136136
);
137137
currentProgress = perc;
138138
}
139+
} else {
140+
const divisionRegOutput = divisionRegex.exec(dat);
141+
if (divisionRegOutput) {
142+
const perc = Math.ceil(parseInt(divisionRegOutput[1]) / parseInt(divisionRegOutput[2]) * 100);
143+
progress?.report(
144+
{
145+
increment: perc - currentProgress,
146+
message: `${perc}%`
147+
}
148+
);
149+
currentProgress = perc;
150+
}
139151
}
152+
140153
if (token?.isCancellationRequested) {
141154
if (childProcess) {
142155
resolve(childProcess);

0 commit comments

Comments
 (0)