Skip to content
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

Enable bracketed paste mode when sending lines to the repl #384

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Odie
Copy link

@Odie Odie commented Jul 14, 2024

The problem

Recently, after returning to some Python projects, I noticed a problem with iron.nvim's core.send_file() function. While the function still pushes all lines to the REPL buffer, each line's indentation increases by one. This issue arose in my environment where I'm using ptpython on macOS.

The fix

Upon investigating, it appears the issue stems from lowlevel.send_to_repl(). The function wasn't initiating bracket paste mode, which seems to be the root of the problem. I implemented a patch that triggers bracketed paste mode before sending code to the REPL, which resolved the issue in my setup. While I'm not certain if this issue is widespread or what other setups it might impact, this solution has worked well for me so far.

I hope this fix can be helpful to others experiencing similar issues!

@Odie Odie force-pushed the fixes/bracketed-paste-mode branch from 66abecd to 9b3772d Compare July 14, 2024 16:15
@Odie Odie force-pushed the fixes/bracketed-paste-mode branch from 9b3772d to c3189c8 Compare July 14, 2024 16:24
@Odie
Copy link
Author

Odie commented Jul 21, 2024

Also note that when configuring the plugin, I’ve had to disable the default format function when using ptpython due to an issue with the bracketed_paste_python function. The function was adding unnecessary carriage returns which caused discrepancies between the content sent to the REPL and the actual buffer content. As a result, errors reported by the REPL did not correspond accurately to the line numbers in the buffer, complicating debugging. Here’s how I configured the plugin:

    require("iron.core").setup({
      config = {
        repl_definition = {
          python = {
            command = "ptpython",
            -- Disabled `format` function to avoid carriage return issues
          },
        },
      },
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant