Skip to content

Commit

Permalink
Match ledger-mode.el fill-paragraph for currency on right
Browse files Browse the repository at this point in the history
  • Loading branch information
bradyt committed Feb 17, 2020
1 parent 0d400e7 commit e1099db
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cone_lib/lib/src/types.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// ignore_for_file: public_member_api_docs

import 'dart:math' show max;

import 'package:petitparser/petitparser.dart';

import 'package:cone_lib/parse.dart';
Expand Down Expand Up @@ -130,8 +132,15 @@ class Posting {
if (amount == null) {
return ' $account';
} else {
final int padding =
52 - 4 - account.length - 2 - amount.toString().length;
final int padding = max(
2,
(amount.commodityOnLeft)
? 52 - 4 - account.length - 2 - amount.toString().length
: 52 -
4 -
account.length -
2 -
amount.quantity.toString().length);
return ' $account ${' ' * padding}$amount'.trimRight();
}
}
Expand Down

0 comments on commit e1099db

Please sign in to comment.