Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(881)

Unified Diff: lib/src/intl/number_format.dart

Issue 834313003: Fix bug with percent formats with no integer part (Closed) Base URL: https://github.com/dart-lang/intl.git@master
Patch Set: Review fixes Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/intl/number_format.dart
diff --git a/lib/src/intl/number_format.dart b/lib/src/intl/number_format.dart
index 2e23d358e7947d871e761cb063ff613886cc5b42..db4c7a4a53204c2eafc9c7df7edb01033a5fbec9 100644
--- a/lib/src/intl/number_format.dart
+++ b/lib/src/intl/number_format.dart
@@ -310,7 +310,7 @@ class NumberFormat {
var integerDigits = _integerDigits(integerPart, extraIntegerDigits);
var digitLength = integerDigits.length;
- if (_hasPrintableIntegerPart(integerPart)) {
+ if (_hasIntegerDigits(integerDigits)) {
_pad(minimumIntegerDigits - digitLength);
for (var i = 0; i < digitLength; i++) {
_addDigit(integerDigits.codeUnitAt(i));
@@ -386,11 +386,12 @@ class NumberFormat {
/**
* Return true if we have a main integer part which is printable, either
- * because we have digits left of the decimal point, or because there are
- * a minimum number of printable digits greater than 1.
+ * because we have digits left of the decimal point (this may include digits
+ * which have been moved left because of percent or permille formatting),
+ * or because the minimum number of printable digits is greater than 1.
*/
- bool _hasPrintableIntegerPart(x) =>
- x > 0 || minimumIntegerDigits > 0;
+ bool _hasIntegerDigits(String digits) =>
+ digits.isNotEmpty || minimumIntegerDigits > 0;
/** A group of methods that provide support for writing digits and other
* required characters into [_buffer] easily.
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698