Skip to content

Commit f55687e

Browse files
committed
Fixing tqdm
1 parent 1385b71 commit f55687e

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

script.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,11 @@ async function runCodeInline() {
233233
// Split output into segments by \n (real newlines)
234234
const segments = fullOutput.split('\n');
235235
const cleanLines = [];
236+
let lastWasTqdm = false;
236237

237-
for (let segment of segments) {
238+
for (let i = 0; i < segments.length; i++) {
239+
const segment = segments[i];
240+
238241
// For each segment, if it contains \r, it's a tqdm progress line being updated
239242
// We only want the LAST update (after the last \r)
240243
if (segment.includes('\r')) {
@@ -247,17 +250,30 @@ async function runCodeInline() {
247250
// Only include if it's the final 100% line
248251
if (lastPart.startsWith('100%')) {
249252
cleanLines.push(lastPart);
253+
lastWasTqdm = true;
254+
} else {
255+
lastWasTqdm = true;
250256
}
251257
// Otherwise skip intermediate tqdm updates
252258
} else {
253259
// Not a tqdm line, include it
260+
// If previous was tqdm 100%, add empty line for separation
261+
if (lastWasTqdm) {
262+
cleanLines.push('');
263+
lastWasTqdm = false;
264+
}
254265
cleanLines.push(lastPart);
255266
}
256267
}
257268
} else {
258269
// No \r, just a regular line
259270
const trimmed = segment.trim();
260271
if (trimmed) {
272+
// If previous was tqdm 100%, add empty line for separation
273+
if (lastWasTqdm) {
274+
cleanLines.push('');
275+
lastWasTqdm = false;
276+
}
261277
cleanLines.push(trimmed);
262278
}
263279
}

0 commit comments

Comments
 (0)