@@ -79,19 +79,31 @@ class EditEngine {
7979 * @param newColumnValue
8080 * @param option
8181 */
82- public async updateRowFileProxy ( file : TFile , columnId : string , newValue : Literal , columns : TableColumn [ ] , ddbbConfig : LocalSettings , option : string ) : Promise < void > {
83- this . onFlyEditions . push ( { file, columnId, newValue, columns, ddbbConfig, option } ) ;
84- clearTimeout ( this . currentTimeout ) ;
82+ public async updateRowFileProxy ( p_file : TFile , p_columnId : string , p_newValue : Literal , p_columns : TableColumn [ ] , p_ddbbConfig : LocalSettings , p_option : string ) : Promise < void > {
83+ await this . onFlyEditions . push ( {
84+ file : p_file ,
85+ columnId : p_columnId ,
86+ newValue : p_newValue ,
87+ columns : p_columns ,
88+ ddbbConfig : p_ddbbConfig ,
89+ option : p_option
90+ } ) ;
91+ if ( this . currentTimeout ) {
92+ clearTimeout ( this . currentTimeout ) ;
93+ }
8594 this . currentTimeout = setTimeout ( async ( ) => {
8695 // Call all onFlyEditions
8796 while ( this . onFlyEditions . length > 0 ) {
88- const { file, columnId, newValue, columns, ddbbConfig, option } = this . onFlyEditions . pop ( ) ;
97+
98+ const { file, columnId, newValue, columns, ddbbConfig, option } = this . onFlyEditions . shift ( ) ;
8999 await this . updateRowFile ( file , columnId , newValue , columns , ddbbConfig , option )
90100 . catch ( ( err ) => {
91101 showDBError ( EditionError . YamlRead , err ) ;
92102 } ) ;
93- this . currentTimeout = null ;
103+ // Delay to avoid overloading the system
104+ await new Promise ( ( resolve ) => setTimeout ( resolve , 25 ) ) ;
94105 }
106+ this . currentTimeout = null ;
95107 } , 250 ) ;
96108 }
97109
0 commit comments