-
Notifications
You must be signed in to change notification settings - Fork 1.4k
PyREPL: Send code using bracketed paste markers #26178
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 all commits
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 |
|---|---|---|
|
|
@@ -99,12 +99,10 @@ 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({ | ||
|
|
@@ -127,8 +125,12 @@ 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) { | ||
| // For the new _pyrepl in Python 3.13+, send code via bracketed paste mode so the REPL | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't recall exact detail, but the indentation logic has been funky and probably worth revisiting with newer models. Maybe there were some nuances with PY_REPL flag + shell integration combination. Also recommend these 4 scenarios when it comes to manually testing and ensuring coverage for run selection of Python code (via shift+enter, or UI): When I say shell integration, I mean both the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| // preserves the code's indentation instead of applying its own auto-indentation. | ||
| // This must happen regardless of the `terminal.shellIntegration.enabled` setting: terminal | ||
| // REPL code is always sent through `sendText` (never `shellIntegration.executeCommand`), so | ||
| // bracketed paste is the only thing preventing progressively increasing indentation. | ||
| if (object.attach_bracket_paste && _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. | ||
|
|
||




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