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(formula): great than equal error (#2758)

Univer65e471dcc2b4
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.ts
index a179a27456..ab094e35d5 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
@@ -393,6 +393,25 @@ describe('lexer nodeMaker test', () => {
')',
]);
});
+
+ it('Great than or equal', () => {
+ expect(lexerTreeBuilder.sequenceNodesBuilder('=A1:B10>=100')).toStrictEqual([
+ {
+ endIndex: 5,
+ nodeType: 4,
+ startIndex: 0,
+ token: 'A1:B10',
+ },
+ '>',
+ '=',
+ {
+ endIndex: 10,
+ nodeType: 1,
+ startIndex: 8,
+ token: '100',
+ },
+ ]);
+ });
});
describe('convertRefersToAbsolute', () => {
diff --git a/packages/engine-formula/src/engine/analysis/lexer-tree-builder.ts b/packages/engine-formula/src/engine/analysis/lexer-tree-builder.ts
index 82e29d9ad0..7d334ab68d 100644
--- a/packages/engine-formula/src/engine/analysis/lexer-tree-builder.ts
+++ b/packages/engine-formula/src/engine/analysis/lexer-tree-builder.ts
@@ -1430,7 +1430,13 @@ export class LexerTreeBuilder extends Disposable {
const nextCurrentString = formulaStringArray[cur + 1];
if (nextCurrentString && OPERATOR_TOKEN_SET.has(currentString + nextCurrentString)) {
this._pushNodeToChildren(trimSegment + currentString + nextCurrentString);
+
+ this._resetSegment();
+ this._addSequenceArray(sequenceArray, currentString, cur, isZeroAdded);
cur++;
+ this._addSequenceArray(sequenceArray, nextCurrentString, cur, isZeroAdded);
+ cur++;
+ continue;
} else {
this._pushNodeToChildren(trimSegment + currentString);
}