-
Notifications
You must be signed in to change notification settings - Fork 1.3k
dont automatically inject PYTHONSTARTUP #24346
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
Changes from 18 commits
154a3e2
377e700
d60f310
6d8ba24
37cd45b
fbcebd2
1bbd0bc
3aa86bf
5f53706
d327903
2db9394
8b5eeb0
7c0b405
0ccb053
40ff863
7dd3f83
3c3bfc9
c1a51ad
4ea5c67
8fb2e24
83dbb90
2f3e787
eaa78f2
d12ae35
f7f8ef6
6b4b097
edb91ba
eaaf338
de99824
dbb2e2a
038c98e
aa07144
490ef8b
c896ce7
59a3116
4fd5369
b40f53f
e527be7
446e95c
1435329
12f7b3e
4a2a5d0
c56fb61
d4b0227
9e0d33d
6fba2a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,6 @@ | |
| // Licensed under the MIT License. | ||
|
|
||
| import { inject, injectable } from 'inversify'; | ||
| import * as path from 'path'; | ||
| import { CancellationToken, Disposable, Event, EventEmitter, Terminal } from 'vscode'; | ||
| import '../../common/extensions'; | ||
| import { IInterpreterService } from '../../interpreter/contracts'; | ||
|
|
@@ -11,7 +10,6 @@ import { captureTelemetry } from '../../telemetry'; | |
| import { EventName } from '../../telemetry/constants'; | ||
| import { ITerminalAutoActivation } from '../../terminals/types'; | ||
| import { ITerminalManager } from '../application/types'; | ||
| import { EXTENSION_ROOT_DIR } from '../constants'; | ||
| import { _SCRIPTS_DIR } from '../process/internal/scripts/constants'; | ||
| import { IConfigurationService, IDisposableRegistry } from '../types'; | ||
| import { | ||
|
|
@@ -33,7 +31,6 @@ export class TerminalService implements ITerminalService, Disposable { | |
| private terminalHelper: ITerminalHelper; | ||
| private terminalActivator: ITerminalActivator; | ||
| private terminalAutoActivator: ITerminalAutoActivation; | ||
| private readonly envVarScript = path.join(EXTENSION_ROOT_DIR, 'python_files', 'pythonrc.py'); | ||
| private readonly executeCommandListeners: Set<Disposable> = new Set(); | ||
| public get onDidCloseTerminal(): Event<void> { | ||
| return this.terminalClosed.event.bind(this.terminalClosed); | ||
|
|
@@ -102,18 +99,29 @@ export class TerminalService implements ITerminalService, Disposable { | |
|
|
||
| if (terminal.shellIntegration) { | ||
| const execution = terminal.shellIntegration.executeCommand(commandLine); | ||
| return await new Promise((resolve) => { | ||
| const listener = this.terminalManager.onDidEndTerminalShellExecution((e) => { | ||
| if (e.execution === execution) { | ||
| this.executeCommandListeners.delete(listener); | ||
| resolve({ execution, exitCode: e.exitCode }); | ||
| return await Promise.race([ | ||
| new Promise<ITerminalExecutedCommand>((resolve) => { | ||
| const listener = this.terminalManager.onDidEndTerminalShellExecution((e) => { | ||
| if (e.execution === execution) { | ||
| this.executeCommandListeners.delete(listener); | ||
| resolve({ execution, exitCode: e.exitCode }); | ||
| } | ||
| }); | ||
| if (listener) { | ||
| this.executeCommandListeners.add(listener); | ||
| } | ||
| }); | ||
| if (listener) { | ||
| this.executeCommandListeners.add(listener); | ||
| } | ||
| traceVerbose(`Shell Integration is enabled, executeCommand: ${commandLine}`); | ||
| }); | ||
| traceVerbose(`Shell Integration is enabled, executeCommand: ${commandLine}`); | ||
| }), | ||
| // Once shell integration is active, hearing back from onDidEndTerminalShellExecution should not take too long. | ||
| new Promise<undefined>((resolve) => { | ||
|
||
| setTimeout(() => { | ||
| traceVerbose(`Execution timed out, falling back to sendText: ${commandLine}`); | ||
| terminal.sendText(commandLine); | ||
| resolve(undefined); | ||
| return undefined; | ||
| }, 5000); | ||
| }), | ||
| ]); | ||
| } else { | ||
| terminal.sendText(commandLine); | ||
| traceVerbose(`Shell Integration is disabled, sendText: ${commandLine}`); | ||
|
|
@@ -136,7 +144,7 @@ export class TerminalService implements ITerminalService, Disposable { | |
| this.terminalShellType = this.terminalHelper.identifyTerminalShell(this.terminal); | ||
| this.terminal = this.terminalManager.createTerminal({ | ||
| name: this.options?.title || 'Python', | ||
| env: { PYTHONSTARTUP: this.envVarScript }, | ||
| env: {}, | ||
| hideFromUser: this.options?.hideFromUser, | ||
| }); | ||
| this.terminalAutoActivator.disableAutoActivation(this.terminal); | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.