From 41807839f02ed6d772175d82fc35716393bb86ca Mon Sep 17 00:00:00 2001 From: Agando Date: Sun, 18 Oct 2026 16:48:18 +0200 Subject: newOS4 v4.6.36: fix CourseModule print-capture swallowing all command output --- modules/ext/course.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'modules/ext/course.js') diff --git a/modules/ext/course.js b/modules/ext/course.js index 3e00229..d3b96de 100644 --- a/modules/ext/course.js +++ b/modules/ext/course.js @@ -175,14 +175,28 @@ class CourseModule { onCommandStart(cmd, args) { if (cmd === 'course') return; - if (this._capActive) { try { this.terminal._popPrintCapture(); } catch (e) {} this._capActive = false; } + // Only capture while an exercise is actually running. Capturing every command + // swallowed all terminal output (pwd/help/version printed nothing). + if (!this._active || !this._active.lesson || !this._active.lesson.exercise) return; + if (this._capActive) { + try { this.terminal._popPrintCapture(); } catch (e) {} + if (this._capOut) { try { this.terminal.print(this._capOut.replace(/\n+$/, '')); } catch (e) {} } + this._capActive = false; + } this._capOut = ''; this._capActive = true; try { this.terminal._pushPrintCapture(txt => { this._capOut = txt; }); } catch (e) { this._capActive = false; } } onCommandExecuted(cmd, args) { - if (this._capActive) { try { this.terminal._popPrintCapture(); } catch (e) {} this._capActive = false; } + let cap = ''; + if (this._capActive) { + cap = this._capOut || ''; + try { this.terminal._popPrintCapture(); } catch (e) {} + this._capActive = false; + } + // Never swallow the user's output: replay it after the capture is popped. + if (cap.trim()) { try { this.terminal.print(cap.replace(/\n+$/, '')); } catch (e) {} } if (!this._active || !this._active.lesson.exercise || cmd === 'course') return; const ex = this._active.lesson.exercise; const line = (cmd + (args.length ? ' ' + args.join(' ') : '')).trim(); -- cgit v1.2.3