@@ -192,7 +192,10 @@ use CommonLibrary::{
192192 Storage :: StorageProvider :: StorageProvider ,
193193} ;
194194
195- use crate :: RunTime :: ApplicationRunTime :: ApplicationRunTime ;
195+ use crate :: {
196+ ApplicationState :: DTO :: WorkspaceFolderStateDTO :: WorkspaceFolderStateDTO ,
197+ RunTime :: ApplicationRunTime :: ApplicationRunTime ,
198+ } ;
196199
197200/// Handler for Wind's MainProcessService.invoke() calls
198201/// Maps Tauri IPC commands to Mountain's internal command system
@@ -1373,6 +1376,7 @@ async fn handle_quick_input_show_input_box(runtime:Arc<ApplicationRunTime>, args
13731376 IsPassword : Some ( Opts . and_then ( |V | V . get ( "password" ) ) . and_then ( |B | B . as_bool ( ) ) . unwrap_or ( false ) ) ,
13741377 Value : Opts . and_then ( |V | V . get ( "value" ) ) . and_then ( |V | V . as_str ( ) ) . map ( |S | S . to_string ( ) ) ,
13751378 Title : Opts . and_then ( |V | V . get ( "title" ) ) . and_then ( |T | T . as_str ( ) ) . map ( |S | S . to_string ( ) ) ,
1379+ IgnoreFocusOut : None ,
13761380 } ;
13771381
13781382 let Result = runtime
@@ -1390,18 +1394,14 @@ async fn handle_quick_input_show_input_box(runtime:Arc<ApplicationRunTime>, args
13901394
13911395/// Return the current workspace folders.
13921396async fn handle_workspaces_get_folders ( runtime : Arc < ApplicationRunTime > ) -> Result < Value , String > {
1393- let Folders = runtime
1394- . Environment
1395- . ApplicationState . Workspace
1396- . GetFolders ( )
1397- . await
1398- . map_err ( |Error | format ! ( "workspaces:getFolders failed: {}" , Error ) ) ?;
1397+ let Workspace = & runtime. Environment . ApplicationState . Workspace ;
1398+ let Folders = Workspace . GetWorkspaceFolders ( ) ;
13991399
14001400 let FolderList : Vec < Value > = Folders
14011401 . iter ( )
14021402 . enumerate ( )
14031403 . map ( |( Index , Folder ) | json ! ( {
1404- "uri" : Folder . Uri ,
1404+ "uri" : Folder . URI . to_string ( ) ,
14051405 "name" : Folder . Name ,
14061406 "index" : Index ,
14071407 } ) )
@@ -1412,38 +1412,43 @@ async fn handle_workspaces_get_folders(runtime:Arc<ApplicationRunTime>) -> Resul
14121412
14131413/// Add a workspace folder.
14141414async fn handle_workspaces_add_folder ( runtime : Arc < ApplicationRunTime > , args : Vec < Value > ) -> Result < Value , String > {
1415- let Uri = args
1415+ use url:: Url ;
1416+
1417+ let UriStr = args
14161418 . first ( )
14171419 . and_then ( |V | V . as_str ( ) )
14181420 . ok_or ( "workspaces:addFolder requires uri as first argument" . to_string ( ) ) ?
14191421 . to_string ( ) ;
14201422
14211423 let Name = args. get ( 1 ) . and_then ( |V | V . as_str ( ) ) . unwrap_or ( "" ) . to_string ( ) ;
14221424
1423- runtime
1424- . Environment
1425- . ApplicationState . Workspace
1426- . AddFolder ( Uri , Name )
1427- . await
1428- . map_err ( |Error | format ! ( "workspaces:addFolder failed: {}" , Error ) ) ?;
1425+ let Workspace = & runtime. Environment . ApplicationState . Workspace ;
1426+ let mut Folders = Workspace . GetWorkspaceFolders ( ) ;
1427+ let Index = Folders . len ( ) ;
1428+ let URI = Url :: parse ( & UriStr ) . map_err ( |E | format ! ( "workspaces:addFolder invalid URI: {}" , E ) ) ?;
1429+ if let Ok ( Folder ) = WorkspaceFolderStateDTO :: New ( URI , Name , Index ) {
1430+ Folders . push ( Folder ) ;
1431+ Workspace . SetWorkspaceFolders ( Folders ) ;
1432+ }
14291433
14301434 Ok ( Value :: Null )
14311435}
14321436
14331437/// Remove a workspace folder by URI.
14341438async fn handle_workspaces_remove_folder ( runtime : Arc < ApplicationRunTime > , args : Vec < Value > ) -> Result < Value , String > {
1435- let Uri = args
1439+ let UriStr = args
14361440 . first ( )
14371441 . and_then ( |V | V . as_str ( ) )
14381442 . ok_or ( "workspaces:removeFolder requires uri as first argument" . to_string ( ) ) ?
14391443 . to_string ( ) ;
14401444
1441- runtime
1442- . Environment
1443- . ApplicationState . Workspace
1444- . RemoveFolder ( Uri )
1445- . await
1446- . map_err ( |Error | format ! ( "workspaces:removeFolder failed: {}" , Error ) ) ?;
1445+ let Workspace = & runtime. Environment . ApplicationState . Workspace ;
1446+ let mut Folders = Workspace . GetWorkspaceFolders ( ) ;
1447+ Folders . retain ( |F | F . URI . to_string ( ) != UriStr ) ;
1448+ for ( I , F ) in Folders . iter_mut ( ) . enumerate ( ) {
1449+ F . Index = I ;
1450+ }
1451+ Workspace . SetWorkspaceFolders ( Folders ) ;
14471452
14481453 Ok ( Value :: Null )
14491454}
@@ -1453,9 +1458,10 @@ async fn handle_workspaces_get_name(runtime:Arc<ApplicationRunTime>) -> Result<V
14531458 let Name = runtime
14541459 . Environment
14551460 . ApplicationState . Workspace
1456- . GetName ( )
1457- . await
1458- . map_err ( |Error | format ! ( "workspaces:getName failed: {}" , Error ) ) ?;
1461+ . GetWorkspaceFolders ( )
1462+ . into_iter ( )
1463+ . next ( )
1464+ . map ( |F | F . GetDisplayName ( ) ) ;
14591465
14601466 Ok ( Name . map ( |N | json ! ( N ) ) . unwrap_or ( Value :: Null ) )
14611467}
@@ -1551,15 +1557,13 @@ async fn handle_search_find_in_files(runtime:Arc<ApplicationRunTime>, args:Vec<V
15511557 let WorkspaceFolders = runtime
15521558 . Environment
15531559 . ApplicationState . Workspace
1554- . GetFolders ( )
1555- . await
1556- . unwrap_or_default ( ) ;
1560+ . GetWorkspaceFolders ( ) ;
15571561
15581562 if WorkspaceFolders . is_empty ( ) {
15591563 return Ok ( json ! ( [ ] ) ) ;
15601564 }
15611565
1562- let RootPath = PathBuf :: from ( & WorkspaceFolders [ 0 ] . Uri . replace ( "file://" , "" ) ) ;
1566+ let RootPath = PathBuf :: from ( & WorkspaceFolders [ 0 ] . URI . to_string ( ) . replace ( "file://" , "" ) ) ;
15631567
15641568 // Build include matcher
15651569 let IncludeMatcher = GlobBuilder :: new ( & IncludeGlob )
@@ -1659,15 +1663,13 @@ async fn handle_search_find_files(runtime:Arc<ApplicationRunTime>, args:Vec<Valu
16591663 let WorkspaceFolders = runtime
16601664 . Environment
16611665 . ApplicationState . Workspace
1662- . GetFolders ( )
1663- . await
1664- . unwrap_or_default ( ) ;
1666+ . GetWorkspaceFolders ( ) ;
16651667
16661668 if WorkspaceFolders . is_empty ( ) {
16671669 return Ok ( json ! ( [ ] ) ) ;
16681670 }
16691671
1670- let RootPath = PathBuf :: from ( & WorkspaceFolders [ 0 ] . Uri . replace ( "file://" , "" ) ) ;
1672+ let RootPath = PathBuf :: from ( & WorkspaceFolders [ 0 ] . URI . to_string ( ) . replace ( "file://" , "" ) ) ;
16711673
16721674 let Matcher = GlobBuilder :: new ( & Pattern )
16731675 . literal_separator ( false )
0 commit comments