@@ -869,15 +869,15 @@ impl Console {
869869 return result;
870870 }
871871
872- // In notebook mode, unexpected browser() or debug() calls (i.e.
873- // without an active debug session) are routed to stdin so the user
874- // can type debug commands in an input box rather than hanging .
872+ // In notebook mode, ` browser()` or ` debug()` calls causing a
873+ // browser prompt outside of an active debugging session are routed
874+ // to stdin so the user can type debug commands in an input box.
875875 if self . session_mode == SessionMode :: Notebook &&
876876 !self . debug_dap . lock ( ) . unwrap ( ) . is_connected
877877 {
878- self . debug_dap . lock ( ) . unwrap ( ) . is_stopped_at_browser = true ;
878+ self . debug_dap . lock ( ) . unwrap ( ) . is_debugging_stdin = true ;
879879 let result = self . handle_input_request ( & info, buf, buflen) ;
880- self . debug_dap . lock ( ) . unwrap ( ) . is_stopped_at_browser = false ;
880+ self . debug_dap . lock ( ) . unwrap ( ) . is_debugging_stdin = false ;
881881 return result;
882882 }
883883
@@ -994,21 +994,17 @@ impl Console {
994994 // package. 50ms seems to be more in line with RStudio (posit-dev/positron#7235).
995995 let polled_events_rx = crossbeam:: channel:: tick ( Duration :: from_millis ( 50 ) ) ;
996996
997- // This is the main kind of message from the frontend that we are expecting.
998- // We either wait for `input_reply` messages on StdIn, or for
999- // `execute_request` on Shell.
1000- let ( r_request_index, stdin_reply_index) = match wait_for {
1001- WaitFor :: ExecuteRequest => ( Some ( select. recv ( & r_request_rx) ) , None ) ,
1002- WaitFor :: InputReply => {
1003- // In notebook mode, also listen for debug commands (e.g. Quit
1004- // from the interrupt handler) while waiting for stdin input.
1005- let r_request_index = if self . session_mode == SessionMode :: Notebook {
1006- Some ( select. recv ( & r_request_rx) )
1007- } else {
1008- None
1009- } ;
1010- ( r_request_index, Some ( select. recv ( & stdin_reply_rx) ) )
1011- } ,
997+ // This is the main kind of message from the frontend that we are
998+ // expecting. We either wait for `input_reply` messages on StdIn, or for
999+ // `execute_request` on Shell. We also listen for R requests, including
1000+ // while waiting on StdIn. Such requests are only expected in Notebook
1001+ // mode when debugging via StdIn. The interrupt handler may send us a
1002+ // Quit command to terminate the debugging session. For simplicity we
1003+ // listen for these requests unconditionally, including in Console sessions.
1004+ let r_request_index = select. recv ( & r_request_rx) ;
1005+ let stdin_reply_index = match wait_for {
1006+ WaitFor :: ExecuteRequest => None ,
1007+ WaitFor :: InputReply => Some ( select. recv ( & stdin_reply_rx) ) ,
10121008 } ;
10131009
10141010 let kernel_request_index = select. recv ( & kernel_request_rx) ;
@@ -1072,16 +1068,16 @@ impl Console {
10721068
10731069 match oper. index ( ) {
10741070 // We've got an execute request from the frontend
1075- i if Some ( i ) == r_request_index => {
1071+ i if i == r_request_index => {
10761072 let req = oper. recv ( & r_request_rx) ;
10771073 let Ok ( req) = req else {
10781074 // The channel is disconnected and empty
10791075 return ConsoleResult :: Disconnected ;
10801076 } ;
10811077
1082- // During stdin-browser ( notebook mode, waiting for input
1083- // at a browser prompt) , the interrupt handler sends
1084- // DebugCommand( Quit) to exit the browser cleanly.
1078+ // When debugging via StdIn in notebook mode, waiting for
1079+ // input at a browser prompt, the interrupt handler may send
1080+ // a Quit command to exit the browser cleanly.
10851081 if matches ! ( wait_for, WaitFor :: InputReply ) {
10861082 if let RRequest :: DebugCommand ( ref cmd) = req {
10871083 let input = crate :: request:: debug_request_command ( cmd. clone ( ) ) ;
0 commit comments