Skip to content

Commit 11a27b4

Browse files
author
Mildred Ki'Lya
committed
LedgerAlign: Better detect decimal point
This commit detect the location of the decimal point consistently in the following circumstances (given g:ledger_decimal_sep='.'): -30 = 0 456.78 It uses the decimal point location if it can be found, and if it cannot, it uses the first character after the first group of digits.
1 parent 17be971 commit 11a27b4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

autoload/ledger.vim

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,15 @@ function! ledger#align_commodity()
373373
if rhs != ''
374374
" Remove everything after the account name (including spaces):
375375
.s/\m^\s\+[^[:space:]].\{-}\zs\(\t\| \).*$//
376-
if g:ledger_decimal_sep == ''
377-
let pos = matchend(rhs, '\m\d[^[:space:]]*')
378-
else
376+
let pos = -1
377+
if g:ledger_decimal_sep != ''
379378
" Find the position of the first decimal separator:
380379
let pos = s:strpos(rhs, '\V' . g:ledger_decimal_sep)
381380
endif
381+
if pos < 0
382+
" Find the position after the first digits
383+
let pos = matchend(rhs, '\m\d[^[:space:]]*')
384+
endif
382385
" Go to the column that allows us to align the decimal separator at g:ledger_align_at:
383386
if pos > 0
384387
call s:goto_col(g:ledger_align_at - pos - 1)

0 commit comments

Comments
 (0)