Skip to content

Can't create terminal with a pseudo tty in the Web #160914

@dbaeumer

Description

@dbaeumer

Here is my code snippet

		const ptyWriteEmitter = new vscode.EventEmitter<string>();
		const pty = {
			onDidWrite: this.ptyWriteEmitter.event,
			open: () => {
				this.ptyWriteEmitter.fire(`\x1b[31m${name}\x1b[0m\r\n\r\n`);
			},
			close: () => {
			},
			handleInput: (data: string) => {
				// Echo the data
				if (data === '\r') {
					data = '\n';
				}
				if (data.charCodeAt(0) === 127) {
					// Delete last character
					this.ptyWriteEmitter.fire('\x1b[D\x1b[P');
					this.inputBuffer.splice(this.inputBuffer.length - 1, 1);
				} else {
					this.ptyWriteEmitter.fire(data === '\n' ? '\r\n' : data);
					this.inputBuffer.push(data);
				}
				if (data === '\n' && this.lineAvailable !== undefined) {
					this.lineAvailable();
				}
			}
		};

		const terminal = window.createTerminal({ name: 'Python Terminal', pty: pty  });
		terminal.show();

Trying to run this creates:

ERR A container element needs to be set with `attachToElement` and be part of the DOM before calling `_open`: Error: A container element needs to be set with `attachToElement` and be part of the DOM before calling `_open`
    at Ui._open (https://main.vscode-cdn.net/insider/b3546b4bb5aff5254ef857cfd68a3da8534c068f/out/vs/workbench/workbench.web.main.js:3097:46503)
    at Ui.setVisible (https://main.vscode-cdn.net/insider/b3546b4bb5aff5254ef857cfd68a3da8534c068f/out/vs/workbench/workbench.web.main.js:3099:2561)
    at h.showPanel (https://main.vscode-cdn.net/insider/b3546b4bb5aff5254ef857cfd68a3da8534c068f/out/vs/workbench/workbench.web.main.js:3097:22123)

Metadata

Metadata

Assignees

Labels

apibugIssue identified by VS Code Team member as probable buginsiders-releasedPatch has been released in VS Code InsidersterminalGeneral terminal issues that don't fall under another labelverifiedVerification succeeded

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions