Skip to content

Commit 726359d

Browse files
committed
Merge pull request #34 from yhlfh/master
fix commodity alignment when amount contains no decimal seperator
2 parents 4538378 + 220fce5 commit 726359d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

autoload/ledger.vim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,11 @@ function! ledger#align_commodity()
371371
let pos = match(rhs, '\V' . g:ledger_decimal_sep)
372372
endif
373373
" Go to the column that allows us to align the decimal separator at g:ledger_align_at:
374-
call s:goto_col(g:ledger_align_at - pos - 1)
374+
if pos > 0
375+
call s:goto_col(g:ledger_align_at - pos - 1)
376+
else
377+
call s:goto_col(g:ledger_align_at - strdisplaywidth(rhs) - 2)
378+
endif
375379
" Append the part of the line that was previously removed:
376380
exe 'normal! a' . rhs
377381
endif
@@ -385,7 +389,7 @@ function! ledger#align_amount_at_cursor()
385389
let pos = match(@", g:ledger_decimal_sep) " Returns zero when the separator is the empty string
386390
" Paste text at the correct column and append/prepend default commodity:
387391
if g:ledger_commodity_before
388-
call s:goto_col(g:ledger_align_at - (pos > 0 ? pos : len(@")) - len(g:ledger_default_commodity) - len(g:ledger_commodity_sep) - 1)
392+
call s:goto_col(g:ledger_align_at - (pos > 0 ? pos : len(@")) - len(g:ledger_default_commodity) - len(g:ledger_commodity_sep) - 1)
389393
exe 'normal! a' . g:ledger_default_commodity . g:ledger_commodity_sep
390394
normal! p
391395
else

0 commit comments

Comments
 (0)