@@ -2382,23 +2382,27 @@ impl Editor {
23822382 self . last_cwd . as_deref ( )
23832383 }
23842384
2385- pub fn trust_workspace ( & mut self ) -> anyhow:: Result < ( ) > {
2385+ pub fn trust_current_workspace ( & mut self ) -> anyhow:: Result < ( ) > {
23862386 let Some ( path) = doc ! ( self ) . path ( ) else {
23872387 bail ! ( "Document does not have a path; you need to add a path to trust it." )
23882388 } ;
23892389 let workspace = helix_loader:: find_workspace_in ( path) . 0 ;
2390+ self . trust_workspace ( workspace)
2391+ }
2392+
2393+ pub fn trust_workspace ( & mut self , workspace : impl AsRef < Path > ) -> anyhow:: Result < ( ) > {
23902394 match trust_db:: trust_path ( & workspace) {
23912395 Err ( e) => bail ! ( "Couldn't edit trust database: {e}" ) ,
23922396 Ok ( is_new_entry) => {
23932397 if is_new_entry {
23942398 self . set_status ( format ! (
23952399 "Workspace '{}' unrestricted; LSPs, debuggers and formatters available." ,
2396- workspace. display( )
2400+ workspace. as_ref ( ) . display( )
23972401 ) )
23982402 } else {
23992403 self . set_status ( format ! (
24002404 "Workspace '{}' is already trusted." ,
2401- workspace. display( )
2405+ workspace. as_ref ( ) . display( )
24022406 ) ) ;
24032407 }
24042408 self . documents_mut ( )
@@ -2409,23 +2413,27 @@ impl Editor {
24092413 Ok ( ( ) )
24102414 }
24112415
2412- pub fn untrust_workspace ( & mut self ) -> anyhow:: Result < ( ) > {
2416+ pub fn untrust_current_workspace ( & mut self ) -> anyhow:: Result < ( ) > {
24132417 let Some ( path) = doc ! ( self ) . path ( ) else {
24142418 bail ! ( "Document does not have a path; it is already untrusted." )
24152419 } ;
24162420 let workspace = helix_loader:: find_workspace_in ( path) . 0 ;
2421+ self . untrust_workspace ( workspace)
2422+ }
2423+
2424+ pub fn untrust_workspace ( & mut self , workspace : impl AsRef < Path > ) -> anyhow:: Result < ( ) > {
24172425 match trust_db:: untrust_path ( & workspace) {
24182426 Err ( e) => bail ! ( "Couldn't edit trust database: {e}" ) ,
24192427 Ok ( was_removed) => {
24202428 if was_removed {
24212429 self . set_status ( format ! (
24222430 "Workspace '{}' restricted; LSPs, formatters and debuggers do not work." ,
2423- workspace. display( )
2431+ workspace. as_ref ( ) . display( )
24242432 ) ) ;
24252433 } else {
24262434 self . set_status ( format ! (
24272435 "Workspace '{}' was already untrusted." ,
2428- workspace. display( )
2436+ workspace. as_ref ( ) . display( )
24292437 ) ) ;
24302438 }
24312439 self . documents_mut ( )
0 commit comments