File tree Expand file tree Collapse file tree 7 files changed +17
-36
lines changed
Expand file tree Collapse file tree 7 files changed +17
-36
lines changed Original file line number Diff line number Diff line change @@ -26,17 +26,15 @@ pub unsafe extern "C-unwind" fn ps_browse_url(url: SEXP) -> anyhow::Result<SEXP>
2626}
2727
2828fn is_help_url ( url : & str ) -> bool {
29- Console :: with ( |con| con . is_help_url ( url) )
29+ Console :: get ( ) . is_help_url ( url)
3030}
3131
3232fn handle_help_url ( url : String ) -> anyhow:: Result < ( ) > {
33- Console :: with ( |con| {
34- let event = HelpEvent :: ShowHelpUrl ( ShowHelpUrlParams {
35- url,
36- kind : ShowHelpUrlKind :: HelpProxy ,
37- } ) ;
38- con. send_help_event ( event)
39- } )
33+ let event = HelpEvent :: ShowHelpUrl ( ShowHelpUrlParams {
34+ url,
35+ kind : ShowHelpUrlKind :: HelpProxy ,
36+ } ) ;
37+ Console :: get ( ) . send_help_event ( event)
4038}
4139
4240unsafe fn ps_browse_url_impl ( url : SEXP ) -> anyhow:: Result < SEXP > {
Original file line number Diff line number Diff line change @@ -891,20 +891,6 @@ impl Console {
891891 } )
892892 }
893893
894- pub fn with < F , T > ( f : F ) -> T
895- where
896- F : FnOnce ( & Console ) -> T ,
897- {
898- f ( Self :: get ( ) )
899- }
900-
901- pub fn with_mut < F , T > ( f : F ) -> T
902- where
903- F : FnOnce ( & mut Console ) -> T ,
904- {
905- f ( Self :: get_mut ( ) )
906- }
907-
908894 pub fn on_main_thread ( ) -> bool {
909895 let thread = std:: thread:: current ( ) ;
910896 thread. id ( ) == unsafe { CONSOLE_THREAD_ID . unwrap ( ) }
Original file line number Diff line number Diff line change @@ -530,7 +530,7 @@ pub fn start_lsp(
530530 r_task ( {
531531 let events_tx = events_tx. clone ( ) ;
532532 move || {
533- Console :: with_mut ( |con| con . set_lsp_channel ( events_tx) ) ;
533+ Console :: get_mut ( ) . set_lsp_channel ( events_tx) ;
534534 }
535535 } ) ;
536536
@@ -577,7 +577,7 @@ pub fn start_lsp(
577577 // from `Console`, at least until someone starts the LSP up again.
578578 r_task ( {
579579 move || {
580- Console :: with_mut ( |con| con . remove_lsp_channel ( ) ) ;
580+ Console :: get_mut ( ) . remove_lsp_channel ( ) ;
581581 }
582582 } ) ;
583583 } )
Original file line number Diff line number Diff line change @@ -244,9 +244,8 @@ impl DeviceContext {
244244 /// comm is connected (i.e. we are connected to Positron) and if we are in
245245 /// [SessionMode::Console] mode.
246246 fn should_use_dynamic_plots ( & self ) -> bool {
247- Console :: with ( |con| {
248- con. is_ui_comm_connected ( ) && con. session_mode ( ) == SessionMode :: Console
249- } )
247+ let console = Console :: get ( ) ;
248+ console. is_ui_comm_connected ( ) && console. session_mode ( ) == SessionMode :: Console
250249 }
251250
252251 /// Deactivation hook
@@ -325,11 +324,9 @@ impl DeviceContext {
325324 }
326325
327326 // Fall back to getting context from Console (for edge cases)
328- Console :: with ( |con| {
329- con. get_execution_context ( ) . unwrap_or_else ( || {
330- // No active request - might be during startup or from R code
331- ( String :: new ( ) , String :: new ( ) )
332- } )
327+ Console :: get ( ) . get_execution_context ( ) . unwrap_or_else ( || {
328+ // No active request - might be during startup or from R code
329+ ( String :: new ( ) , String :: new ( ) )
333330 } )
334331 }
335332
Original file line number Diff line number Diff line change @@ -300,7 +300,7 @@ fn handle_comm_open_help(comm: CommSocket) -> amalthea::Result<bool> {
300300
301301 // Send the help event channel to the main R thread so it can
302302 // emit help events, to be delivered over the help comm.
303- Console :: with_mut ( |con| con . set_help_fields ( help_event_tx, r_port) ) ;
303+ Console :: get_mut ( ) . set_help_fields ( help_event_tx, r_port) ;
304304
305305 Ok ( true )
306306 } )
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ pub(crate) fn resource_loaded_namespaces() -> anyhow::Result<()> {
3838pub ( crate ) async fn ns_populate_srcref ( ns_name : String ) -> anyhow:: Result < ( ) > {
3939 if let Some ( ( uri, contents) ) = ns_populate_srcref_without_vdoc_insertion ( ns_name) . await ? {
4040 // Register the virtual document for the namespace
41- Console :: with_mut ( |con| con . insert_virtual_document ( uri, contents) ) ;
41+ Console :: get_mut ( ) . insert_virtual_document ( uri, contents) ;
4242 } ;
4343
4444 Ok ( ( ) )
@@ -53,7 +53,7 @@ async fn ns_populate_srcref_without_vdoc_insertion(
5353
5454 // Don't redo the work if we already did it. We don't expect a namespace to change.
5555 #[ cfg( not( test) ) ]
56- if Console :: with ( |con| con . has_virtual_document ( & ark_ns_uri ( & ns_name) ) ) {
56+ if Console :: get ( ) . has_virtual_document ( & ark_ns_uri ( & ns_name) ) {
5757 return Ok ( None ) ;
5858 }
5959
Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ fn source_r_profile(path: &PathBuf) {
105105 text : message,
106106 } ) ;
107107
108- Console :: with ( |con| con . get_iopub_tx ( ) . send ( message) . unwrap ( ) )
108+ Console :: get ( ) . get_iopub_tx ( ) . send ( message) . unwrap ( )
109109}
110110
111111fn find_site_r_profile ( r_home : & PathBuf ) -> Option < PathBuf > {
You can’t perform that action at this time.
0 commit comments