From 63e72b997e06e7927444f7b1c3d8cd75a0012278 Mon Sep 17 00:00:00 2001 From: Davis Vaughan Date: Mon, 23 Sep 2024 14:28:39 -0400 Subject: [PATCH] Update `on_console_input()` comments --- crates/ark/src/interface.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/ark/src/interface.rs b/crates/ark/src/interface.rs index c4e531726..30f33a59f 100644 --- a/crates/ark/src/interface.rs +++ b/crates/ark/src/interface.rs @@ -1150,12 +1150,15 @@ impl RMain { /// this when allocating the buffer, but we don't abuse that. /// https://github.com/wch/r-source/blob/20c9590fd05c54dba6c9a1047fb0ba7822ba8ba2/src/include/Defn.h#L1863-L1865 /// - /// In the case of receiving too much input, we simply trim the string and - /// log the issue, executing the rest. Ideally the front end will break up - /// large inputs, preventing this from being necessary. The important thing - /// is to avoid a crash, and it seems that we need to copy something into - /// R's buffer to keep the REPL in a good state. - /// https://github.com/posit-dev/positron/issues/1326#issuecomment-1745389921 + /// Due to `buffer_console_input()`, we should only ever write 1 line of + /// console input to R's internal buffer at a time. R calls + /// `read_console()` back if it needs more input, allowing us to provide + /// the next line. + /// + /// In the case of receiving too much input within a SINGLE line, we + /// propagate up an informative `amalthea::Error::InvalidConsoleInput` + /// error, which is turned into an R error and thrown in a POD context. + /// This is a fairly pathelogical case that we never expect to occur. fn on_console_input( buf: *mut c_uchar, buflen: c_int,