@@ -1308,31 +1308,33 @@ This is a Positron limitation we plan to fix. In the meantime, you can:
1308
1308
}
1309
1309
1310
1310
/// Invoked by R to write output to the console.
1311
- fn write_console ( & mut self , buf : * const c_char , _buflen : i32 , otype : i32 ) {
1311
+ fn write_console ( buf : * const c_char , _buflen : i32 , otype : i32 ) {
1312
1312
let content = match console_to_utf8 ( buf) {
1313
1313
Ok ( content) => content,
1314
1314
Err ( err) => panic ! ( "Failed to read from R buffer: {err:?}" ) ,
1315
1315
} ;
1316
1316
1317
+ if !RMain :: is_initialized ( ) {
1318
+ // During init, consider all output to be part of the startup banner
1319
+ unsafe { R_BANNER . push_str ( & content) } ;
1320
+ return ;
1321
+ }
1322
+
1323
+ let r_main = RMain :: get_mut ( ) ;
1324
+
1317
1325
// To capture the current `debug: <call>` output, for use in the debugger's
1318
1326
// match based fallback
1319
- self . dap . handle_stdout ( & content) ;
1327
+ r_main . dap . handle_stdout ( & content) ;
1320
1328
1321
1329
let stream = if otype == 0 {
1322
1330
Stream :: Stdout
1323
1331
} else {
1324
1332
Stream :: Stderr
1325
1333
} ;
1326
1334
1327
- if !RMain :: is_initialized ( ) {
1328
- // During init, consider all output to be part of the startup banner
1329
- self . banner_output . push_str ( & content) ;
1330
- return ;
1331
- }
1332
-
1333
1335
// If active execution request is silent don't broadcast
1334
1336
// any output
1335
- if let Some ( ref req) = self . active_request {
1337
+ if let Some ( ref req) = r_main . active_request {
1336
1338
if req. request . silent {
1337
1339
return ;
1338
1340
}
@@ -1348,7 +1350,7 @@ This is a Positron limitation we plan to fix. In the meantime, you can:
1348
1350
// differentiate, but that could change in the future:
1349
1351
// https://github.com/posit-dev/positron/issues/1881
1350
1352
if otype == 0 && is_auto_printing ( ) {
1351
- self . autoprint_output . push_str ( & content) ;
1353
+ r_main . autoprint_output . push_str ( & content) ;
1352
1354
return ;
1353
1355
}
1354
1356
@@ -1357,7 +1359,7 @@ This is a Positron limitation we plan to fix. In the meantime, you can:
1357
1359
name : stream,
1358
1360
text : content,
1359
1361
} ) ;
1360
- self . iopub_tx . send ( message) . unwrap ( ) ;
1362
+ r_main . iopub_tx . send ( message) . unwrap ( ) ;
1361
1363
}
1362
1364
1363
1365
/// Invoked by R to change busy state
@@ -1681,8 +1683,7 @@ fn new_cstring(x: String) -> CString {
1681
1683
1682
1684
#[ no_mangle]
1683
1685
pub extern "C" fn r_write_console ( buf : * const c_char , buflen : i32 , otype : i32 ) {
1684
- let main = RMain :: get_mut ( ) ;
1685
- main. write_console ( buf, buflen, otype) ;
1686
+ RMain :: write_console ( buf, buflen, otype) ;
1686
1687
}
1687
1688
1688
1689
#[ no_mangle]
0 commit comments