diff options
| author | Agando <roduccomm@gmail.com> | 2026-10-18 16:48:18 +0200 |
|---|---|---|
| committer | Agando <roduccomm@gmail.com> | 2026-10-18 16:48:18 +0200 |
| commit | 41807839f02ed6d772175d82fc35716393bb86ca (patch) | |
| tree | 53a9ed22921291232794f07eeb0addf922733719 /modules/ext/course.js | |
| parent | 0442af2553d7e1447391d16bca79d2462959d91b (diff) | |
newOS4 v4.6.36: fix CourseModule print-capture swallowing all command output
Diffstat (limited to 'modules/ext/course.js')
| -rw-r--r-- | modules/ext/course.js | 18 |
1 files changed, 16 insertions, 2 deletions
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(); |