Skip to content

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

Closed

Description

@DanTup

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

Activity

  1. DanTup commented on Oct 8, 2020

    @DanTup
    ContributorAuthor

    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);
  2. changed the title [-]Pseudoterminal output does not appear after open event[/-] [+]Pseudoterminal output does not appear f emitted before open() event fires[/+] on Oct 8, 2020
  3. added
    bug
    on Nov 4, 2020
  4. added
    terminal
    on Nov 4, 2020
  5. Tyriar commented on Oct 12, 2021

    @Tyriar
    Contributor

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

  6. added
    *as-designed
    on Oct 12, 2021
  7. DanTup commented on Oct 13, 2021

    @DanTup
    ContributorAuthor

    Daniel Imms (@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).

  8. Tyriar commented on Oct 13, 2021

    @Tyriar
    Contributor

    Will do, thanks

  9. removed
    *as-designed
    on Oct 13, 2021
  10. added
    unreleased
    insiders-released
    and removed
    unreleased
    on Oct 25, 2021
  11. added
    verified
    on Oct 28, 2021
  12. locked and limited conversation to collaborators on Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

apibuginsiders-releasedterminalverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions