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.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(formula): array input (#3097)
Univer774d09c00d1f
diff --git a/packages/engine-formula/src/engine/analysis/__tests__/lexer-tree-builder.spec.ts b/packages/engine-formula/src/engine/analysis/__tests__/lexer-tree-builder.spec.tsindex ab094e35d5..0d36b91040 100644--- a/packages/engine-formula/src/engine/analysis/__tests__/lexer-tree-builder.spec.ts+++ b/packages/engine-formula/src/engine/analysis/__tests__/lexer-tree-builder.spec.ts@@ -196,6 +196,16 @@ describe('lexer nodeMaker test', () => {const node = lexerTreeBuilder.treeBuilder('=(TODAY())') as LexerNode;expect(JSON.stringify(node.serialize())).toStrictEqual('{"token":"R_1","st":-1,"ed":-1,"children":[{"token":"TODAY","st":1,"ed":5,"children":[]}]}');});++ it('array parameter number', () => {+ const node = lexerTreeBuilder.treeBuilder('={-700000,120000,150000,180000,210000,260000}') as LexerNode;+ expect(JSON.stringify(node.serialize())).toStrictEqual('{"token":"R_1","st":-1,"ed":-1,"children":["{-700000,120000,150000,180000,210000,260000}"]}');+ });++ it('array parameter string', () => {+ const node = lexerTreeBuilder.treeBuilder('={"2007/1/1", "2008/1/1"}') as LexerNode;+ expect(JSON.stringify(node.serialize())).toStrictEqual('{"token":"R_1","st":-1,"ed":-1,"children":["{\\"2007/1/1\\", \\"2008/1/1\\"}"]}');+ });});describe('check error', () => {diff --git a/packages/engine-formula/src/engine/analysis/lexer-tree-builder.ts b/packages/engine-formula/src/engine/analysis/lexer-tree-builder.tsindex 7d334ab68d..ffa4da47b2 100644--- a/packages/engine-formula/src/engine/analysis/lexer-tree-builder.ts+++ b/packages/engine-formula/src/engine/analysis/lexer-tree-builder.ts@@ -1192,7 +1192,6 @@ export class LexerTreeBuilder extends Disposable {} else if (currentString === matchToken.DOUBLE_QUOTATION &&this.isSingleQuotationClose() &&- this.isBracesClose() &&this.isSquareBracketClose()) {if (this.isDoubleQuotationClose()) {@@ -1373,7 +1372,8 @@ export class LexerTreeBuilder extends Disposable {this._checkSimilarErrorToken(currentString, cur, formulaStringArray) &&this.isSingleQuotationClose() &&this.isDoubleQuotationClose() &&- this.isSquareBracketClose()+ this.isSquareBracketClose() &&+ this.isBracesClose()) {this._pushNodeToChildren(this._segment);@@ -1398,7 +1398,8 @@ export class LexerTreeBuilder extends Disposable {OPERATOR_TOKEN_SET.has(currentString) &&this.isSingleQuotationClose() &&this.isDoubleQuotationClose() &&- this.isSquareBracketClose()+ this.isSquareBracketClose() &&+ this.isBracesClose()) {let trimSegment = this._segment.trim();