Skip to content

Commit 2e3355c

Browse files
authored
Fix trailing CR character with omni completion on Windows (#152)
1 parent 281346a commit 2e3355c

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

autoload/ledger.vim

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ endf
671671
" Use current line as input to ledger entry and replace with output. If there
672672
" are errors, they are echoed instead.
673673
function! ledger#entry() abort
674-
let l:output = systemlist(s:ledger_cmd(g:ledger_main, join(['entry', getline('.')])))
674+
let l:output = split(system(s:ledger_cmd(g:ledger_main, join(['entry', getline('.')]))), '\n')
675675
" Filter out warnings
676676
let l:output = filter(l:output, "v:val !~? '^Warning: '")
677677
" Errors may occur
@@ -695,7 +695,7 @@ endfunc
695695
" Returns:
696696
" Ledger's output as a String.
697697
function! ledger#report(file, args) abort
698-
let l:output = systemlist(s:ledger_cmd(a:file, a:args))
698+
let l:output = split(system(s:ledger_cmd(a:file, a:args)), '\n')
699699
if v:shell_error " If there are errors, show them in a quickfix/location list.
700700
call s:quickfix_populate(l:output)
701701
call s:quickfix_toggle('Errors', 'Unable to parse errors')
@@ -742,7 +742,7 @@ function! ledger#register(file, args) abort
742742
\ "--prepend-format='%(filename):%(beg_line) '",
743743
\ a:args
744744
\ ]))
745-
call s:quickfix_populate(systemlist(l:cmd))
745+
call s:quickfix_populate(split(system(l:cmd), '\n'))
746746
call s:quickfix_toggle('Register report')
747747
endf
748748

@@ -761,7 +761,7 @@ function! ledger#reconcile(file, account, target_amount) abort
761761
\ shellescape(a:account)
762762
\ ]))
763763
let l:file = expand(a:file) " Needed for #show_balance() later
764-
call s:quickfix_populate(systemlist(l:cmd))
764+
call s:quickfix_populate(split(system(l:cmd), '\n'))
765765
if s:quickfix_toggle('Reconcile ' . a:account, 'Nothing to reconcile')
766766
let g:ledger_target_amount = a:target_amount
767767
" Show updated account balance upon saving, as long as the quickfix window is open
@@ -805,7 +805,7 @@ function! ledger#show_balance(file, ...) abort
805805
\ "--format='%(scrub(get_at(display_total, 0)))|%(scrub(get_at(display_total, 1)))|%(quantity(scrub(get_at(display_total, 1))))'",
806806
\ (empty(g:ledger_default_commodity) ? '' : '-X ' . shellescape(g:ledger_default_commodity))
807807
\ ]))
808-
let l:output = systemlist(l:cmd)
808+
let l:output = split(system(l:cmd), '\n')
809809
" Errors may occur, for example, when the account has multiple commodities
810810
" and g:ledger_default_commodity is empty.
811811
if v:shell_error

ftplugin/ledger.vim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,12 @@ function! s:collect_completion_data() "{{{1
400400
let transactions = ledger#transactions()
401401
let cache = {'descriptions': [], 'tags': {}, 'accounts': {}}
402402
if exists('g:ledger_accounts_cmd')
403-
let accounts = systemlist(g:ledger_accounts_cmd)
403+
let accounts = split(system(g:ledger_accounts_cmd), '\n')
404404
else
405405
let accounts = ledger#declared_accounts()
406406
endif
407407
if exists('g:ledger_descriptions_cmd')
408-
let cache.descriptions = systemlist(g:ledger_descriptions_cmd)
408+
let cache.descriptions = split(system(g:ledger_descriptions_cmd), '\n')
409409
endif
410410
for xact in transactions
411411
if !exists('g:ledger_descriptions_cmd')
@@ -494,10 +494,10 @@ endf "}}}
494494

495495
function! s:autocomplete_account_or_payee(argLead, cmdLine, cursorPos) "{{{2
496496
return (a:argLead =~# '^@') ?
497-
\ map(filter(systemlist(g:ledger_bin . ' -f ' . shellescape(expand(g:ledger_main)) . ' payees'),
497+
\ map(filter(split(system(g:ledger_bin . ' -f ' . shellescape(expand(g:ledger_main)) . ' payees'), '\n'),
498498
\ "v:val =~? '" . strpart(a:argLead, 1) . "' && v:val !~? '^Warning: '"), '"@" . escape(v:val, " ")')
499499
\ :
500-
\ map(filter(systemlist(g:ledger_bin . ' -f ' . shellescape(expand(g:ledger_main)) . ' accounts'),
500+
\ map(filter(split(system(g:ledger_bin . ' -f ' . shellescape(expand(g:ledger_main)) . ' accounts'), '\n'),
501501
\ "v:val =~? '" . a:argLead . "' && v:val !~? '^Warning: '"), 'escape(v:val, " ")')
502502
endf "}}}
503503

0 commit comments

Comments
 (0)