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 | 824d6cd3c61488c120c0226d1929324f2741fafc (patch) | |
| tree | 1d2651ac411cb86d7c5c36b619d72924cabc4751 /modules/ext/course.js | |
| parent | cdf391ed5817f4b15d8312955ad38e31992e062b (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(); |