Factor out handle_active_request()
to correct multiline input request issue
#568
+267
−71
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#4901
The problem was that in something like:
if you send that whole selection, then we'd process the
val <- readline("prompt>")
line, but then R callsread_console()
back and we'd just immediately shovepaste0(val, "-suffix")
through as the reply to the readline request! We need to use theprompt_info()
to recognize that an intermediate expression has put us into aninput_request
state, and handle that before we handlepending_lines
.The ordering of our state machine is now:
I've accomplished this by factoring out
handle_active_request()
. This takes that big if/else branch related to the active request and gives it its own function. The logic in that if/else was actually pretty tricky, and I think it is much cleaner now. It also allows us to sneak inhandle_pending_lines()
between the input request check and closing out the active request.