Skip to content

Commit

Permalink
fix(formula): array input (#3097)
Browse files Browse the repository at this point in the history
  • Loading branch information
DR-Univer authored Aug 22, 2024
1 parent 014dd67 commit 774d09c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,6 @@ export class LexerTreeBuilder extends Disposable {
} else if (
currentString === matchToken.DOUBLE_QUOTATION &&
this.isSingleQuotationClose() &&
this.isBracesClose() &&
this.isSquareBracketClose()
) {
if (this.isDoubleQuotationClose()) {
Expand Down Expand Up @@ -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);

Expand All @@ -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();

Expand Down

0 comments on commit 774d09c

Please sign in to comment.