Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix(sheet): maximum call stack (#4088)

Dushusird6d2e3fc409b
diff --git a/packages/sheets-ui/src/controllers/utils/range-tools.ts b/packages/sheets-ui/src/controllers/utils/range-tools.ts
index dce6a4bcae..c47e3b9aa8 100644
--- a/packages/sheets-ui/src/controllers/utils/range-tools.ts
+++ b/packages/sheets-ui/src/controllers/utils/range-tools.ts
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import { IUniverInstanceService, ObjectMatrix, UniverInstanceType } from '@univerjs/core';
import type { IAccessor, ICellData, IObjectMatrixPrimitiveType, IRange, Workbook } from '@univerjs/core';
+import { IUniverInstanceService, ObjectMatrix, UniverInstanceType } from '@univerjs/core';
export interface IDiscreteRange {
rows: number[];
@@ -68,8 +68,9 @@ export function virtualizeDiscreteRanges(ranges: IDiscreteRange[]): {
const totalRanges: IRange[] = [];
ranges.forEach((r) => {
- totalRows.push(...r.rows);
- totalCols.push(...r.cols);
+ // Do not use destructuring, otherwise Maximum call stack size exceeded will occur
+ totalRows = totalRows.concat(r.rows);
+ totalCols = totalCols.concat(r.cols);
});
totalRows = Array.from(new Set(totalRows)).sort((a, b) => a - b);