Avoid crashing when given input longer than R's buffer #202
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.
Addresses posit-dev/positron#1767
Which is this TODO left for ark posit-dev/positron#1326 (comment)
Ideally the frontend will break long inputs up for us, making this redundant, but until then we need to at least avoid crashing.
I've taken the same approach as RStudio, which is to just trim the input if it exceeds the buffer size. This isn't ever a practical issue in RStudio because it seems to split large chunks of input by newlines, and sends one line at a time to R's buffer.
Our previous behavior of just returning without copying anything into the buffer wasn't working, and would result in a crash, presumably because R was expecting something to get copied into the buffer after a read-console iteration.