Skip to content

Commit c7e37fb

Browse files
authored
fix: allow processing multiple terminal responses from WASM (#103)
1 parent 2ede417 commit c7e37fb

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/terminal.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,13 +1749,19 @@ export class Terminal implements ITerminalCore {
17491749
*
17501750
* Without this, shells like nushell that rely on cursor position queries
17511751
* will hang waiting for a response that never comes.
1752+
*
1753+
* Note: We loop to read all pending responses, not just one. This is important
1754+
* when multiple queries are processed in a single write() call (e.g., when
1755+
* buffered data is written all at once during terminal initialization).
17521756
*/
17531757
private processTerminalResponses(): void {
17541758
if (!this.wasmTerm) return;
17551759

1756-
// Read any pending responses from the WASM terminal
1757-
const response = this.wasmTerm.readResponse();
1758-
if (response) {
1760+
// Read all pending responses from the WASM terminal
1761+
// Multiple responses can be queued if a single write() contained multiple queries
1762+
while (true) {
1763+
const response = this.wasmTerm.readResponse();
1764+
if (response === null) break;
17591765
// Send response back to the PTY via onData
17601766
// This is the same path as user keyboard input
17611767
this.dataEmitter.fire(response);

0 commit comments

Comments
 (0)