Skip to content

Commit

Permalink
Fix an error in comma resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
borgar committed Oct 2, 2024
1 parent df3720d commit 3dc39f8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/tokenize.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ export function tokenize (pattern) {
break;
}
}
// if we just matched a break, then deal with any unresolved commas
if (unresolvedCommas.length && token.raw === ';') {
unresolvedCommas.length = 0;
}
// if we just matched a num operator, then deal with any unresolved commas
if (unresolvedCommas.length && isNumOp(token.raw)) {
unresolvedCommas.forEach(d => (d.type = TOKEN_GROUP));
Expand Down
7 changes: 7 additions & 0 deletions test/numfmt-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,10 @@ test('Tokenizer is not case sensitive:', t => {
t.format('dDdD', 1234, 'Monday');
t.end();
});

test('Comma resolution test:', t => {
t.format('#,,"M"', 6000000, '6M');
t.format('#,,"M";', 6000000, '6M');
t.format('#,,"M";#,,"M";0', 6000000, '6M');
t.end();
});

0 comments on commit 3dc39f8

Please sign in to comment.