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

extra content inserted into terminal when running python file #23284

Open
amunger opened this issue Apr 23, 2024 · 4 comments
Open

extra content inserted into terminal when running python file #23284

amunger opened this issue Apr 23, 2024 · 4 comments
Assignees
Labels
triage-needed Needs assignment to the proper sub-team

Comments

@amunger
Copy link

amunger commented Apr 23, 2024

Testing #23272

unrelated to the TPI
Close all terminal sessions, this doesn't seem to repro when another terminal is open.
Clicking run file will run the file in the terminal, but also insert extra content on the next terminal input.

Recording 2024-04-23 at 09 24 11

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Apr 23, 2024
@karthiknadig
Copy link
Member

@Tyriar This seems like something to do with how terminal handles send text. All we are doing on the python extension side are constructing the execution command and doing a send text.

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Apr 23, 2024
@Tyriar
Copy link
Member

Tyriar commented Apr 24, 2024

All we are doing on the python extension side are constructing the execution command and doing a send text.

Do you mean you're doing both executeCommand and sendText? You should only be doing the first.

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Apr 24, 2024
@karthiknadig
Copy link
Member

karthiknadig commented Apr 24, 2024

No, we just do sendText. What I meant was, we use the shell type to figure out which activation script to use and then send that script to the terminal via sendText

Here is where we do this:

public async activateEnvironmentInTerminal(
terminal: Terminal,
options?: TerminalActivationOptions,
): Promise<boolean> {
if (this.activatedTerminals.has(terminal)) {
return this.activatedTerminals.get(terminal)!;
}
const deferred = createDeferred<boolean>();
this.activatedTerminals.set(terminal, deferred.promise);
const terminalShellType = this.helper.identifyTerminalShell(terminal);
const activationCommands = await this.helper.getEnvironmentActivationCommands(
terminalShellType,
options?.resource,
options?.interpreter,
);
let activated = false;
if (activationCommands) {
for (const command of activationCommands) {
terminal.show(options?.preserveFocus);
traceVerbose(`Command sent to terminal: ${command}`);
terminal.sendText(command);
await this.waitForCommandToProcess(terminalShellType);
activated = true;
}
}
deferred.resolve(activated);
return activated;
}

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Apr 24, 2024
@Tyriar
Copy link
Member

Tyriar commented Apr 25, 2024

Enabling trace logging mode and checking the Terminal output channel will give some information about where the characters are coming from. For example typing "abc", see the sending data and parsing data lines:

2024-04-25 07:55:38.081 [debug] sending data "a" [[97]]
2024-04-25 07:55:38.115 [debug] parsing data "�[?25l�[93ma�[97m�[2m�[3mpplicationFrameHost.exe�[6;4H�[?25h" [[27,91,63,50,53,108,27,91,57,51,109,97,27,91,57,55,109,27,91,50,109,27,91,51,109,112,112,108,105,99,97,116,105,111,110,70,114,97,109,101,72,111,115,116,46,101,120,101,27,91,54,59,52,72,27,91,63,50,53,104]]
2024-04-25 07:55:38.125 [debug] parsing data "�[m" [[27,91,109]]
2024-04-25 07:55:38.167 [debug] TextAreaSyncAddon#sync: text changed to "applicationFrameHost.exe" []
2024-04-25 07:55:38.168 [debug] TextAreaSyncAddon#sync: text changed to "applicationFrameHost.exe" []
2024-04-25 07:55:38.405 [debug] sending data "b" [[98]]
2024-04-25 07:55:38.432 [debug] parsing data "�[93m�ab�[97m�[2m�[3mc�[m�[21X�" [[27,91,57,51,109,8,97,98,27,91,57,55,109,27,91,50,109,27,91,51,109,99,27,91,109,27,91,50,49,88,8]]
2024-04-25 07:55:38.487 [debug] TextAreaSyncAddon#sync: text changed to "abc" []
2024-04-25 07:55:38.488 [debug] TextAreaSyncAddon#sync: text changed to "abc" []
2024-04-25 07:55:38.802 [debug] sending data "c" [[99]]
2024-04-25 07:55:38.830 [debug] parsing data "�[?25l�[93m�[6;3Habc�[?25h" [[27,91,63,50,53,108,27,91,57,51,109,27,91,54,59,51,72,97,98,99,27,91,63,50,53,104]]
2024-04-25 07:55:38.853 [debug] parsing data "�[m" [[27,91,109]]
2024-04-25 07:55:38.882 [debug] TextAreaSyncAddon#sync: text changed to "abc" []
2024-04-25 07:55:38.883 [debug] TextAreaSyncAddon#sync: text changed to "abc" []

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

3 participants