Skip to content

Commit bf1967f

Browse files
committed
read all pending responses via loop
1 parent 65aeac9 commit bf1967f

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

lib/terminal.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,13 +1749,18 @@ 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+
let response: string | null;
1763+
while ((response = this.wasmTerm.readResponse()) !== null) {
17591764
// Send response back to the PTY via onData
17601765
// This is the same path as user keyboard input
17611766
this.dataEmitter.fire(response);

0 commit comments

Comments
 (0)