@@ -21,6 +21,7 @@ import {
21
21
TerminalShellType ,
22
22
} from './types' ;
23
23
import { traceVerbose } from '../../logging' ;
24
+ import { getConfiguration } from '../vscodeApis/workspaceApis' ;
24
25
25
26
@injectable ( )
26
27
export class TerminalService implements ITerminalService , Disposable {
@@ -69,17 +70,20 @@ export class TerminalService implements ITerminalService, Disposable {
69
70
this . terminal ! . show ( true ) ;
70
71
}
71
72
72
- return this . executeCommand ( text ) ;
73
+ return this . executeCommand ( text , false ) ;
73
74
}
74
75
/** @deprecated */
75
76
public async sendText ( text : string ) : Promise < void > {
76
77
await this . ensureTerminal ( ) ;
77
78
if ( ! this . options ?. hideFromUser ) {
78
79
this . terminal ! . show ( true ) ;
79
80
}
80
- this . terminal ! . sendText ( text ) ;
81
+ this . terminal ! . sendText ( text , false ) ;
81
82
}
82
- public async executeCommand ( commandLine : string ) : Promise < IExecuteCommandResult | undefined > {
83
+ public async executeCommand (
84
+ commandLine : string ,
85
+ isPythonShell : boolean ,
86
+ ) : Promise < IExecuteCommandResult | undefined > {
83
87
const terminal = this . terminal ! ;
84
88
if ( ! this . options ?. hideFromUser ) {
85
89
terminal . show ( true ) ;
@@ -102,12 +106,18 @@ export class TerminalService implements ITerminalService, Disposable {
102
106
} ) ;
103
107
await promise ;
104
108
}
105
- // python in a shell , exit code is undefined . startCommand event happen, we call end command event
106
- if ( terminal . shellIntegration ) {
109
+ // If shell integration for python is disabled, use sendText inside REPL regardless of upstream shell integration setting.
110
+ const config = getConfiguration ( 'python' ) ;
111
+ const pythonrcSetting = config . get < boolean > ( 'terminal.shellIntegration.enabled' ) ;
112
+ if ( isPythonShell && ! pythonrcSetting ) {
113
+ terminal . sendText ( commandLine ) ;
114
+ return undefined ;
115
+ } else if ( terminal . shellIntegration ) {
116
+ // python in a shell , exit code is undefined . startCommand event happen, we call end command event
107
117
// TODO: Await the python REPL execute promise here. So we know python repl launched for sure before executing other python code.
108
118
// So we would not be interrupted.
109
119
110
- await this . serviceContainer . get < ICodeExecutionService > ( ICodeExecutionService ) . replActive ;
120
+ // await this.serviceContainer.get<ICodeExecutionService>(ICodeExecutionService).replActive; getting undefined
111
121
112
122
const execution = terminal . shellIntegration . executeCommand ( commandLine ) ;
113
123
traceVerbose ( `Shell Integration is enabled, executeCommand: ${ commandLine } ` ) ;
0 commit comments