Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pseudoterminal output does not appear f emitted before open() event fires #108298

Closed
DanTup opened this issue Oct 8, 2020 · 4 comments
Closed
Assignees
Labels
api bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders terminal Integrated terminal issues verified Verification succeeded
Milestone

Comments

@DanTup
Copy link
Contributor

DanTup commented Oct 8, 2020

Not sure what's happening here, but content written to an emitter for a pseudo terminal doesn't seem to show up outside of the open function:

const emitter = new vs.EventEmitter<string>();
const pseudoterminal: vs.Pseudoterminal = {
	close: () => { },
	onDidWrite: emitter.event,
	open: () => { emitter.fire("Hello world!\r\n"); },
};
const terminal = vs.window.createTerminal({ name: `Danny Test Terminal`, pty: pseudoterminal });
emitter.fire(`Test 1\r\n`);
terminal.show();
emitter.fire(`Test 2\r\n`);
setTimeout(() => emitter.fire(`Test 3\r\n`), 100);

I only see the first line in the terminal:

Screenshot 2020-10-08 at 12 18 05

@DanTup
Copy link
Contributor Author

DanTup commented Oct 8, 2020

Seems like this may be a delay in the terminal subscribing to the event. Unsure if this is a bug/unintended race, or by design (if intended, I think it should be documented against the API somewhere).

This works:

const emitter = new vs.EventEmitter<string>();
let terminal!: vs.Terminal;
const terminalCreation = new Promise((resolve) => {
	const pseudoterminal: vs.Pseudoterminal = {
		close: () => { },
		onDidWrite: emitter.event,
		open: () => { emitter.fire("Hello world!\r\n"); resolve(); },
	};
	terminal = vs.window.createTerminal({ name: `Danny Test Terminal`, pty: pseudoterminal });
});
await terminalCreation;
terminal.show();
setTimeout(() => emitter.fire("Test 3\r\n"), 0);

@DanTup DanTup changed the title Pseudoterminal output does not appear after open event Pseudoterminal output does not appear f emitted before open() event fires Oct 8, 2020
@meganrogge meganrogge added the bug Issue identified by VS Code Team member as probable bug label Nov 4, 2020
@meganrogge meganrogge added this to the Backlog milestone Nov 4, 2020
@Tyriar Tyriar added api terminal Integrated terminal issues labels Nov 4, 2020
@Tyriar
Copy link
Member

Tyriar commented Oct 12, 2021

I think it's by design, open is the callback when everything is ready, you should only write after open is called.

@Tyriar Tyriar closed this as completed Oct 12, 2021
@Tyriar Tyriar added the *as-designed Described behavior is as designed label Oct 12, 2021
@DanTup
Copy link
Contributor Author

DanTup commented Oct 13, 2021

@Tyriar my suggestion above was that if this was by-design, it was called out in the docs. It's difficult to know when things are bugs or not if they're only documented in GH issues that are really difficult to search and may just result in more people filing issues (or, having bugs).

@Tyriar
Copy link
Member

Tyriar commented Oct 13, 2021

Will do, thanks

@Tyriar Tyriar reopened this Oct 13, 2021
@Tyriar Tyriar removed the *as-designed Described behavior is as designed label Oct 13, 2021
@Tyriar Tyriar modified the milestones: Backlog, October 2021 Oct 13, 2021
@Tyriar Tyriar closed this as completed in b498b7d Oct 25, 2021
@alexr00 alexr00 added the verified Verification succeeded label Oct 28, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Dec 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders terminal Integrated terminal issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants
@DanTup @Tyriar @meganrogge @alexr00 and others