File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
hledger/Hledger/Cli/Commands Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -88,9 +88,13 @@ aregister opts@CliOpts{rawopts_=rawopts,reportspec_=rspec} j = do
8888 [] -> error' $ help <> " .\n Please provide an account name or a (case-insensitive, infix, regexp) pattern."
8989 (a: as) -> return (a, map T. pack as)
9090 let
91- -- keep synced with findMatchedByArgument's matching
91+ -- related: findMatchedByArgument
92+ -- Here, we select the first matched according to display order -
93+ -- ie the first declared if the accounts are declaraed, otherwise the alphanumerically first.
9294 acct = fromMaybe (error' $ help <> " ,\n but " ++ show apat++ " did not match any account." ) -- PARTIAL:
93- . firstMatch $ journalAccountNamesDeclaredOrImplied j
95+ . firstMatch $
96+ sortAccountNamesByDeclaration j False $
97+ journalAccountNamesDeclaredOrImplied j
9498 firstMatch = case toRegexCI $ T. pack apat of
9599 Right re -> find (regexMatchText re)
96100 Left _ -> const Nothing
Original file line number Diff line number Diff line change @@ -42,9 +42,10 @@ As a quick rule of thumb:
4242
4343Note this command's non-standard, and required, first argument; it specifies the account whose register will be shown.
4444You can write the account's name, or (to save typing) a case-insensitive infix regular expression matching the name,
45- which selects the alphabetically first matched account.
46- (For example, if you have ` assets:personal checking ` and ` assets:business checking ` ,
47- ` hledger areg checking ` would select ` assets:business checking ` .)
45+ which selects the first matched account (in [ display order] ( hledger.md#account-display-order ) if any, otherwise alphabetically).
46+ For example, if you have ` assets:personal checking ` and ` assets:business checking ` ,
47+ ` hledger areg checking ` will select ` assets:business checking `
48+ (unless you used ` account ` directives to change their display order).
4849
4950Transactions involving subaccounts of this account will also be shown.
5051` aregister ` ignores depth limits, so its final total will always match
You can’t perform that action at this time.
0 commit comments