File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
src/BlazorDatasheet.DataStructures/Intervals
test/BlazorDatasheet.Test/Commands Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -435,7 +435,15 @@ public virtual void Restore(MergeableIntervalStoreRestoreData<T> restoreData)
435435 {
436436 foreach ( var shift in restoreData . Shifts )
437437 {
438- foreach ( var interval in GetIntervals ( shift . Index , int . MaxValue ) )
438+ var intervals = GetIntervals ( shift . Index , int . MaxValue ) ;
439+ IEnumerable < OrderedInterval < T > > intervalsOrdered ;
440+
441+ if ( shift . Amount > 0 )
442+ intervalsOrdered = intervals . OrderBy ( i => i . Start ) ;
443+ else
444+ intervalsOrdered = intervals . OrderByDescending ( i => i . Start ) ;
445+
446+ foreach ( var interval in intervalsOrdered )
439447 {
440448 _intervals . Remove ( interval . Start ) ;
441449 interval . Shift ( - shift . Amount ) ;
Original file line number Diff line number Diff line change @@ -184,4 +184,17 @@ public void Remove_Col_Intersects_With_Edge_Of_region_Restores_On_Undo()
184184 cmd . Undo ( sheet ) ;
185185 sheet . GetFormat ( 0 , 1 ) ? . HorizontalTextAlign . Should ( ) . Be ( TextAlign . Center ) ;
186186 }
187+
188+ [ Test ]
189+ public void Remove_Col_Before_Format_And_Undo_Does_Not_Throw_Error ( )
190+ {
191+ Assert . DoesNotThrow ( ( ) =>
192+ {
193+ var sheet = new Sheet ( 10 , 10 ) ;
194+ sheet . Range ( "E:E" ) . Format = new CellFormat ( ) { HorizontalTextAlign = TextAlign . Center } ;
195+ sheet . Range ( "D:D" ) . Format = new CellFormat ( ) { NumberFormat = "C1" , FontWeight = "bold" } ;
196+ sheet . Columns . RemoveAt ( 2 ) ;
197+ sheet . Commands . Undo ( ) ;
198+ } ) ;
199+ }
187200}
You can’t perform that action at this time.
0 commit comments