Resolve REPL regression on indentation, disable PyREPL only when shell integration is enabled by anthonykim1 · Pull Request #25296 · microsoft/vscode-python

Expand Up @@ -99,10 +99,12 @@ export class CodeExecutionHelper implements ICodeExecutionHelper { const endLineVal = activeEditor?.selection?.end.line ?? 0; const emptyHighlightVal = activeEditor?.selection?.isEmpty ?? true; let smartSendSettingsEnabledVal = true; let shellIntegrationEnabled = false; const configuration = this.serviceContainer.get<IConfigurationService>(IConfigurationService); if (configuration) { const pythonSettings = configuration.getSettings(this.activeResourceService.getActiveResource()); smartSendSettingsEnabledVal = pythonSettings.REPL.enableREPLSmartSend; shellIntegrationEnabled = pythonSettings.terminal.shellIntegration.enabled; }
const input = JSON.stringify({ Expand All @@ -125,6 +127,16 @@ export class CodeExecutionHelper implements ICodeExecutionHelper { await this.moveToNextBlock(lineOffset, activeEditor); }
// For new _pyrepl for Python3.13+ && !shellIntegration, we need to send code via bracketed paste mode. if (object.attach_bracket_paste && !shellIntegrationEnabled && _replType === ReplType.terminal) { let trimmedNormalized = object.normalized.replace(/\n$/, ''); if (trimmedNormalized.endsWith(':\n')) { // In case where statement is unfinished via :, truncate so auto-indentation lands nicely. trimmedNormalized = trimmedNormalized.replace(/\n$/, ''); } return `\u001b[200~${trimmedNormalized}\u001b[201~`; }
return parse(object.normalized); } catch (ex) { traceError(ex, 'Python: Failed to normalize code for execution in terminal'); Expand Down