@@ -28,7 +28,13 @@ import { matrixMap } from "../../../functions/helpers";
2828import { PositionMap } from "../../../helpers/cells/position_map" ;
2929import { toXC } from "../../../helpers/coordinates" ;
3030import { lazy } from "../../../helpers/misc" ;
31- import { excludeTopLeft , positionsUnion , positionToZone , union } from "../../../helpers/zones" ;
31+ import {
32+ cellPositions ,
33+ excludeTopLeft ,
34+ positionsUnion ,
35+ positionToZone ,
36+ union ,
37+ } from "../../../helpers/zones" ;
3238import { onIterationEndEvaluationRegistry } from "../../../registries/evaluation_registry" ;
3339import { _t } from "../../../translation" ;
3440import { Format } from "../../../types/format" ;
@@ -162,10 +168,9 @@ export class Evaluator {
162168 return new PositionSet ( this . getters . getSheetIds ( ) ) ;
163169 }
164170
165- evaluateCells ( positions : CellPosition [ ] ) {
171+ evaluateCells ( positions : RangeSet ) {
166172 const start = performance . now ( ) ;
167- const rangesToCompute = new RangeSet ( ) ;
168- rangesToCompute . addManyPositions ( positions ) ;
173+ const rangesToCompute = positions ;
169174 const arrayFormulasPositions = this . getArrayFormulasImpactedByChangesOf ( positions ) ;
170175 rangesToCompute . addMany ( this . getCellsDependingOn ( rangesToCompute ) ) ;
171176 rangesToCompute . addMany ( arrayFormulasPositions ) ;
@@ -175,19 +180,21 @@ export class Evaluator {
175180 console . debug ( "evaluate Cells" , performance . now ( ) - start , "ms" ) ;
176181 }
177182
178- private getArrayFormulasImpactedByChangesOf ( positions : Iterable < CellPosition > ) : RangeSet {
183+ private getArrayFormulasImpactedByChangesOf ( ranges : RangeSet ) : RangeSet {
179184 const impactedRanges = new RangeSet ( ) ;
180185
181- for ( const position of positions ) {
182- const content = this . getters . getCell ( position ) ?. content ;
183- const arrayFormulaPosition = this . getArrayFormulaSpreadingOn ( position ) ;
184- if ( arrayFormulaPosition !== undefined ) {
185- // take into account new collisions.
186- impactedRanges . addPosition ( arrayFormulaPosition ) ;
187- }
188- if ( ! content ) {
189- // The previous content could have blocked some array formulas
190- impactedRanges . addPosition ( position ) ;
186+ for ( const range of ranges ) {
187+ for ( const position of cellPositions ( range . sheetId , range . zone ) ) {
188+ const content = this . getters . getCell ( position ) ?. content ;
189+ const arrayFormulaPosition = this . getArrayFormulaSpreadingOn ( position ) ;
190+ if ( arrayFormulaPosition !== undefined ) {
191+ // take into account new collisions.
192+ impactedRanges . addPosition ( arrayFormulaPosition ) ;
193+ }
194+ if ( ! content ) {
195+ // The previous content could have blocked some array formulas
196+ impactedRanges . addPosition ( position ) ;
197+ }
191198 }
192199 }
193200 for ( const range of [ ...impactedRanges ] ) {
0 commit comments