Skip to content

Commit

Permalink
fix(sheet): parseValue handle number (#4049)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dushusir authored Nov 30, 2024
1 parent a4b38af commit 59b95fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,10 @@ describe('Test EndEditController', () => {
it('should handle escaped quotes in strings', () => {
expect(normalizeStringByLexer('="He said, ""Hello, .5!"""')).toBe('="He said, ""Hello, .5!"""');
});
it('Illegal strings should not be modified', () => {
expect(normalizeStringByLexer('=SUM(11, 2 2, 33)')).toBe('=SUM(11, 2 2, 33)');
expect(normalizeStringByLexer('=SUM(11, 123 123, 33)')).toBe('=SUM(11, 123 123, 33)');
});
});
});
});
2 changes: 1 addition & 1 deletion packages/sheets-ui/src/controllers/utils/char-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function normalizeFormulaString(str: string, normalStr: string, lexerTreeBuilder
}
// Entering =.07/0.1 in a cell will automatically convert to =0.07/0.1
// Entering =1.0+2.00 in a cell will automatically convert to =1+2
else if (typeof parsedValue.v === 'number') {
else if (typeof parsedValue.v === 'number' && (parsedValue.z === undefined || !numfmt.isDate(parsedValue.z))) {
const v = `${parsedValue.v}`;
const startIndex = node.startIndex + totalOffset + 1;
const endIndex = node.endIndex + totalOffset + 2;
Expand Down

0 comments on commit 59b95fa

Please sign in to comment.