Skip to content

Commit

Permalink
fix(formula): node maker handle blank (#4347)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dushusir authored Jan 6, 2025
1 parent e34c664 commit 2fbe824
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -714,5 +714,22 @@ describe('lexer nodeMaker test', () => {
const result = lexerTreeBuilder.moveFormulaRefOffset('=sum(A$1:B$3)', 1, 1, true);
expect(result).toStrictEqual('=sum(B$2:C$4)');
});

it('sheet name quote', () => {
let result = lexerTreeBuilder.moveFormulaRefOffset("= 'dv-test'!F26", 0, 1, true);
expect(result).toStrictEqual("= 'dv-test'!F27");

result = lexerTreeBuilder.moveFormulaRefOffset("=SUM( 'dv-test'!F26)", 0, 1, true);
expect(result).toStrictEqual("=SUM( 'dv-test'!F27)");

result = lexerTreeBuilder.moveFormulaRefOffset("=SUM( 'dv-test'!F26)", 0, -1, true);
expect(result).toStrictEqual("=SUM( 'dv-test'!F25)");

result = lexerTreeBuilder.moveFormulaRefOffset("=SUM( 'dv-test'!F26)", 1, 0, true);
expect(result).toStrictEqual("=SUM( 'dv-test'!G26)");

result = lexerTreeBuilder.moveFormulaRefOffset("=SUM( 'dv-test'!F26)", -1, 0, true);
expect(result).toStrictEqual("=SUM( 'dv-test'!E26)");
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,13 @@ export class LexerTreeBuilder extends Disposable {
} else if (currentString === matchToken.SINGLE_QUOTATION && this.isDoubleQuotationClose()) {
if (this.isSingleQuotationClose()) {
this._openSingleQuotation();

// If the current segment is blank, reset the segment.
// Process the space before the double single quotes of sheet name.
// e.g. = 'dv-test'!C27
if (this._segmentCount() === 0) {
this._resetSegment();
}
} else {
const nextCurrentString = formulaStringArray[cur + 1];
if (nextCurrentString && nextCurrentString === matchToken.SINGLE_QUOTATION) {
Expand Down

0 comments on commit 2fbe824

Please sign in to comment.