@@ -99,10 +99,12 @@ export class CodeExecutionHelper implements ICodeExecutionHelper {
9999 const endLineVal = activeEditor ?. selection ?. end . line ?? 0 ;
100100 const emptyHighlightVal = activeEditor ?. selection ?. isEmpty ?? true ;
101101 let smartSendSettingsEnabledVal = true ;
102+ let shellIntegrationEnabled = false ;
102103 const configuration = this . serviceContainer . get < IConfigurationService > ( IConfigurationService ) ;
103104 if ( configuration ) {
104105 const pythonSettings = configuration . getSettings ( this . activeResourceService . getActiveResource ( ) ) ;
105106 smartSendSettingsEnabledVal = pythonSettings . REPL . enableREPLSmartSend ;
107+ shellIntegrationEnabled = pythonSettings . terminal . shellIntegration . enabled ;
106108 }
107109
108110 const input = JSON . stringify ( {
@@ -125,6 +127,16 @@ export class CodeExecutionHelper implements ICodeExecutionHelper {
125127 await this . moveToNextBlock ( lineOffset , activeEditor ) ;
126128 }
127129
130+ // For new _pyrepl for Python3.13+ && !shellIntegration, we need to send code via bracketed paste mode.
131+ if ( object . attach_bracket_paste && ! shellIntegrationEnabled && _replType === ReplType . terminal ) {
132+ let trimmedNormalized = object . normalized . replace ( / \n $ / , '' ) ;
133+ if ( trimmedNormalized . endsWith ( ':\n' ) ) {
134+ // In case where statement is unfinished via :, truncate so auto-indentation lands nicely.
135+ trimmedNormalized = trimmedNormalized . replace ( / \n $ / , '' ) ;
136+ }
137+ return `\u001b[200~${ trimmedNormalized } \u001b[201~` ;
138+ }
139+
128140 return parse ( object . normalized ) ;
129141 } catch ( ex ) {
130142 traceError ( ex , 'Python: Failed to normalize code for execution in terminal' ) ;
0 commit comments