mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Fix a bug with editing numbers in some locales.
Summary: Adds a new test for formatting and fix several related bugs it uncovered: 1. When editing a number with "," decimal separator, ensure it opens in the editor with "," (rather than ".", the original bug motivating this). 2. When guessing number format, set maxDecimals when it's needed (otherwise, e.g. "$1.234", or "4.5%" weren't guessed as numeric) 3. When guessing number format, ignore whitespace when deciding if guessed format is correct (otherwise percents can't be guessed in locales which add "%" with a non-breaking space before it). Test Plan: Added a test case that exercises all fixed behaviors. Reviewers: paulfitz Reviewed By: paulfitz Subscribers: paulfitz Differential Revision: https://phab.getgrist.com/D4177
This commit is contained in:
@@ -230,7 +230,7 @@ describe("NumberParse", function() {
|
||||
assert.deepEqual(parser.guessOptions(["$1"]), {numMode: "currency", decimals: 0});
|
||||
assert.deepEqual(parser.guessOptions(["$1.2"]), {numMode: "currency", decimals: 0});
|
||||
assert.deepEqual(parser.guessOptions(["$1.23"]), {numMode: "currency"});
|
||||
assert.deepEqual(parser.guessOptions(["$1.234"]), {numMode: "currency"});
|
||||
assert.deepEqual(parser.guessOptions(["$1.234"]), {numMode: "currency", maxDecimals: 3});
|
||||
|
||||
// Otherwise decimal places are guessed based on trailing zeroes
|
||||
assert.deepEqual(parser.guessOptions(["$1.0"]), {numMode: "currency", decimals: 1});
|
||||
|
||||
Reference in New Issue
Block a user