Open Odie opened 3 months ago
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
},
},
},
}
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!