Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for trailing CR character with omni completion on Windows. #152

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions autoload/ledger.vim
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ endf
" Use current line as input to ledger entry and replace with output. If there
" are errors, they are echoed instead.
function! ledger#entry() abort
let l:output = systemlist(s:ledger_cmd(g:ledger_main, join(['entry', getline('.')])))
let l:output = split(system(s:ledger_cmd(g:ledger_main, join(['entry', getline('.')]))), '\n')
" Filter out warnings
let l:output = filter(l:output, "v:val !~? '^Warning: '")
" Errors may occur
Expand All @@ -695,7 +695,7 @@ endfunc
" Returns:
" Ledger's output as a String.
function! ledger#report(file, args) abort
let l:output = systemlist(s:ledger_cmd(a:file, a:args))
let l:output = split(system(s:ledger_cmd(a:file, a:args)), '\n')
if v:shell_error " If there are errors, show them in a quickfix/location list.
call s:quickfix_populate(l:output)
call s:quickfix_toggle('Errors', 'Unable to parse errors')
Expand Down Expand Up @@ -742,7 +742,7 @@ function! ledger#register(file, args) abort
\ "--prepend-format='%(filename):%(beg_line) '",
\ a:args
\ ]))
call s:quickfix_populate(systemlist(l:cmd))
call s:quickfix_populate(split(system(l:cmd), '\n'))
call s:quickfix_toggle('Register report')
endf

Expand All @@ -761,7 +761,7 @@ function! ledger#reconcile(file, account, target_amount) abort
\ shellescape(a:account)
\ ]))
let l:file = expand(a:file) " Needed for #show_balance() later
call s:quickfix_populate(systemlist(l:cmd))
call s:quickfix_populate(split(system(l:cmd), '\n'))
if s:quickfix_toggle('Reconcile ' . a:account, 'Nothing to reconcile')
let g:ledger_target_amount = a:target_amount
" Show updated account balance upon saving, as long as the quickfix window is open
Expand Down Expand Up @@ -805,7 +805,7 @@ function! ledger#show_balance(file, ...) abort
\ "--format='%(scrub(get_at(display_total, 0)))|%(scrub(get_at(display_total, 1)))|%(quantity(scrub(get_at(display_total, 1))))'",
\ (empty(g:ledger_default_commodity) ? '' : '-X ' . shellescape(g:ledger_default_commodity))
\ ]))
let l:output = systemlist(l:cmd)
let l:output = split(system(l:cmd), '\n')
" Errors may occur, for example, when the account has multiple commodities
" and g:ledger_default_commodity is empty.
if v:shell_error
Expand Down
8 changes: 4 additions & 4 deletions ftplugin/ledger.vim
Original file line number Diff line number Diff line change
Expand Up @@ -400,12 +400,12 @@ function! s:collect_completion_data() "{{{1
let transactions = ledger#transactions()
let cache = {'descriptions': [], 'tags': {}, 'accounts': {}}
if exists('g:ledger_accounts_cmd')
let accounts = systemlist(g:ledger_accounts_cmd)
let accounts = split(system(g:ledger_accounts_cmd), '\n')
else
let accounts = ledger#declared_accounts()
endif
if exists('g:ledger_descriptions_cmd')
let cache.descriptions = systemlist(g:ledger_descriptions_cmd)
let cache.descriptions = split(system(g:ledger_descriptions_cmd), '\n')
endif
for xact in transactions
if !exists('g:ledger_descriptions_cmd')
Expand Down Expand Up @@ -494,10 +494,10 @@ endf "}}}

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

Expand Down
Loading