feat: Bracketed Paste for Terminal Line Sending #591
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds bracketed paste functionality to the terminal line sending feature, particularly beneficial for REPLs of whitespace-sensitive languages like Python.
For additional context, please see conrad irwin's blog page: https://cirw.in/blog/bracketed-paste
Problem
When sending multiple lines of code to a REPL (like IPython), the default behavior can lead to incorrect execution due to inconsistent indentation or premature code evaluation.
For example, a function with whitespace partway through will execute before reading the rest of the function.
Solution
Implemented bracketed paste mode for sending lines to the terminal. This approach wraps the sent text in special escape sequences, signaling the receiving program to treat the input as a single paste operation.
Key benefits:
Implementation Details
send_line_to_terminalfunction to include bracketed paste escape sequences when use_bracketed_paste is trueUsage
Users can enable bracketed paste mode when sending lines to the terminal:
This allows users to selectively use bracketed paste mode when needed, while maintaining compatibility with existing configurations.
The current "Sending lines to the terminal" docs example would be updated from:
to
Impact
This enhancement significantly improves the user experience when working with REPLs, particularly for languages like Python, where indentation is crucial. It allows for more reliable and predictable code execution within the Neovim terminal integration.
Testing
All feedback is welcome!