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

Don't fire onDidEndTerminalShellExecution with exitCode undefined immediately after first onDidChangeTerminalShellIntegration #221399

Closed
Tyriar opened this issue Jul 10, 2024 · 2 comments
Assignees
Labels
api bug Issue identified by VS Code Team member as probable bug *not-reproducible Issue cannot be reproduced by VS Code Team member as described terminal General terminal issues that don't fall under another label

Comments

@Tyriar
Copy link
Member

Tyriar commented Jul 10, 2024

I think what is causing problems for @anthonykim1 is that calling executeCommand immediately after onDidChangeTerminalShellIntegration would fire multiple times and end up triggering an invalid onDidEndTerminalShellExecution with exitCode=undefined but the execution was set when it shouldn't have been. We should suppress this event if possible.

@Tyriar Tyriar added bug Issue identified by VS Code Team member as probable bug api terminal General terminal issues that don't fall under another label labels Jul 10, 2024
@Tyriar Tyriar added this to the July 2024 milestone Jul 10, 2024
@Tyriar Tyriar self-assigned this Jul 10, 2024
Tyriar added a commit that referenced this issue Jul 11, 2024
Looking into this exact thing later in #221399 anyway
@Tyriar Tyriar modified the milestones: July 2024, August 2024 Jul 22, 2024
@Tyriar
Copy link
Member Author

Tyriar commented Aug 4, 2024

Can not reproduce this, maybe something was happening in the profile of the terminal that was launched?

@Tyriar Tyriar closed this as completed Aug 4, 2024
@Tyriar Tyriar added the *not-reproducible Issue cannot be reproduced by VS Code Team member as described label Aug 4, 2024
@anthonykim1
Copy link
Contributor

Not sure what has changed but I dont get the undefined exitCode like I demoed, but rather 0,1 depending on the actual result of executeCommand, which is great:

Code being used:

        const myTerm = window.createTerminal();
        window.onDidChangeTerminalShellIntegration(async ({ terminal, shellIntegration }) => {
            if (terminal === myTerm) {
                const execution = shellIntegration.executeCommand('echo "Hello world"');
                
                window.onDidEndTerminalShellExecution((event) => {
                    if (event.execution === execution) {
                        console.log(`Command exited with code ${event.exitCode}`); 
                        traceLog(`HERE ${event.exitCode} HERE I AM WITH THE EXIT CODE`);

                    }
                });
            }
        });

@Tyriar Tyriar removed this from the August 2024 milestone Aug 29, 2024
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Sep 18, 2024
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 *not-reproducible Issue cannot be reproduced by VS Code Team member as described terminal General terminal issues that don't fall under another label
Projects
None yet
Development

No branches or pull requests

2 participants