@@ -30,7 +30,7 @@ use std::path::{Path, PathBuf};
3030use std:: env;
3131use regex:: Regex ;
3232use crate :: { constants:: * , oyarn, Sy } ;
33- use super :: config:: { self , default_profile_name, get_configuration, ConfigEntry , ConfigFile , RefreshMode } ;
33+ use super :: config:: { self , default_profile_name, get_configuration, ConfigEntry , ConfigFile } ;
3434use super :: entry_point:: { EntryPoint , EntryPointMgr } ;
3535use super :: file_mgr:: FileMgr ;
3636use super :: import_resolver:: ImportCache ;
@@ -1372,7 +1372,7 @@ impl Odoo {
13721372 }
13731373
13741374 fn handle_file_update ( session : & mut SessionInfo , file_uris : & Vec < Uri > ) {
1375- if session. sync_odoo . config . refresh_mode == RefreshMode :: Off || session . sync_odoo . state_init == InitState :: NOT_READY {
1375+ if session. sync_odoo . state_init == InitState :: NOT_READY {
13761376 return
13771377 }
13781378 for uri in file_uris. iter ( ) {
@@ -1383,7 +1383,7 @@ impl Odoo {
13831383 session. log_message ( MessageType :: INFO , format ! ( "File update: {}" , path. sanitize( ) ) ) ;
13841384 let ( valid, updated) = Odoo :: update_file_cache ( session, path. clone ( ) , None , -100 ) ;
13851385 if valid && updated {
1386- Odoo :: update_file_index ( session, path, true , false , true ) ;
1386+ Odoo :: update_file_index ( session, path, false , true ) ;
13871387 }
13881388 }
13891389 }
@@ -1399,7 +1399,7 @@ impl Odoo {
13991399 text: params. text_document. text} ] ) , params. text_document . version ) ;
14001400 if valid {
14011401 session. sync_odoo . opened_files . push ( path. sanitize ( ) ) ;
1402- if session. sync_odoo . config . refresh_mode == RefreshMode :: Off || session . sync_odoo . state_init == InitState :: NOT_READY {
1402+ if session. sync_odoo . state_init == InitState :: NOT_READY {
14031403 return
14041404 }
14051405 let tree = session. sync_odoo . path_to_main_entry_tree ( & path) ;
@@ -1413,15 +1413,15 @@ impl Odoo {
14131413 for custom_entry in ep_mgr. borrow ( ) . custom_entry_points . iter ( ) {
14141414 if custom_entry. borrow ( ) . path == tree_path. sanitize ( ) {
14151415 if updated{
1416- Odoo :: update_file_index ( session, path, true , true , false ) ;
1416+ Odoo :: update_file_index ( session, path, true , false ) ;
14171417 }
14181418 return ;
14191419 }
14201420 }
14211421 EntryPointMgr :: create_new_custom_entry_for_path ( session, & tree_path. sanitize ( ) , & path. sanitize ( ) ) ;
14221422 SyncOdoo :: process_rebuilds ( session) ;
14231423 } else if updated {
1424- Odoo :: update_file_index ( session, path, true , true , false ) ;
1424+ Odoo :: update_file_index ( session, path, true , false ) ;
14251425 }
14261426 }
14271427 }
@@ -1487,7 +1487,7 @@ impl Odoo {
14871487 }
14881488
14891489 pub fn handle_did_rename ( session : & mut SessionInfo , params : RenameFilesParams ) {
1490- if session. sync_odoo . config . refresh_mode == RefreshMode :: Off || session . sync_odoo . state_init == InitState :: NOT_READY {
1490+ if session. sync_odoo . state_init == InitState :: NOT_READY {
14911491 return
14921492 }
14931493 for f in params. files . iter ( ) {
@@ -1518,7 +1518,7 @@ impl Odoo {
15181518 }
15191519
15201520 pub fn handle_did_create ( session : & mut SessionInfo , params : CreateFilesParams ) {
1521- if session. sync_odoo . config . refresh_mode == RefreshMode :: Off || session . sync_odoo . state_init == InitState :: NOT_READY {
1521+ if session. sync_odoo . state_init == InitState :: NOT_READY {
15221522 return
15231523 }
15241524 for f in params. files . iter ( ) {
@@ -1543,7 +1543,7 @@ impl Odoo {
15431543 }
15441544
15451545 pub fn handle_did_delete ( session : & mut SessionInfo , params : DeleteFilesParams ) {
1546- if session. sync_odoo . config . refresh_mode == RefreshMode :: Off || session . sync_odoo . state_init == InitState :: NOT_READY {
1546+ if session. sync_odoo . state_init == InitState :: NOT_READY {
15471547 return
15481548 }
15491549 for f in params. files . iter ( ) {
@@ -1563,10 +1563,10 @@ impl Odoo {
15631563 let version = params. text_document . version ;
15641564 let ( valid, updated) = Odoo :: update_file_cache ( session, path. clone ( ) , Some ( & params. content_changes ) , version) ;
15651565 if valid && updated {
1566- if ( matches ! ( session . sync_odoo . config . refresh_mode , RefreshMode :: Off | RefreshMode :: OnSave ) ) || session. sync_odoo . state_init == InitState :: NOT_READY {
1566+ if session. sync_odoo . state_init == InitState :: NOT_READY {
15671567 return
15681568 }
1569- Odoo :: update_file_index ( session, path, false , false , false ) ;
1569+ Odoo :: update_file_index ( session, path, false , false ) ;
15701570 }
15711571 }
15721572 }
@@ -1577,10 +1577,9 @@ impl Odoo {
15771577 return ; //config file update, handled by the config file handler
15781578 }
15791579 session. log_message ( MessageType :: INFO , format ! ( "File saved: {}" , path. sanitize( ) ) ) ;
1580- if session. sync_odoo . config . refresh_mode != RefreshMode :: OnSave || session. sync_odoo . state_init == InitState :: NOT_READY {
1581- return
1582- }
1583- Odoo :: update_file_index ( session, path, true , false , false ) ;
1580+ return ;
1581+ //No need to update the index on save, as the file change event will do it
1582+ //Odoo::update_file_index(session, path,true, false, false);
15841583 }
15851584
15861585 // return (valid, updated) booleans
@@ -1595,9 +1594,9 @@ impl Odoo {
15951594 ( false , false )
15961595 }
15971596
1598- pub fn update_file_index ( session : & mut SessionInfo , path : PathBuf , is_save : bool , _is_open : bool , force_delay : bool ) {
1597+ pub fn update_file_index ( session : & mut SessionInfo , path : PathBuf , _is_open : bool , force_delay : bool ) {
15991598 if matches ! ( path. extension( ) . and_then( OsStr :: to_str) , Some ( ext) if [ "py" , "xml" , "csv" ] . contains( & ext) ) || Odoo :: is_config_workspace_file ( session, & path) {
1600- SessionInfo :: request_update_file_index ( session, & path, is_save , force_delay) ;
1599+ SessionInfo :: request_update_file_index ( session, & path, force_delay) ;
16011600 }
16021601 }
16031602
0 commit comments