Skip to content

Commit c4db328

Browse files
author
Lifepillar
committed
Filter out warnings when autocompleting commands.
When autocompleting accounts or payees in the command line, one may get warnings, for instance when the source file has checks like the following: tag CSV check tag('CSV') =~ /PAYPAL/ ? \ (has_tag('via') && (tag('via') =~ /PayPal/)) || (payee =~ /PayPal/) : 1 Note that Ledger may emit warnings even when --strict is not passed. So g:ledger_extra_options (see earlier commits) does not fix completion issues completely. This commit addresses the problem by filtering out lines that start with `Warning: `. This works as long as warning messages are one line messages (and the user does have top level accounts called `Warning: `!).
1 parent 39530f3 commit c4db328

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ftplugin/ledger.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,10 @@ endf "}}}
411411
function! s:autocomplete_account_or_payee(argLead, cmdLine, cursorPos) "{{{2
412412
return (a:argLead =~ '^@') ?
413413
\ map(filter(systemlist(g:ledger_bin . ' -f ' . shellescape(expand(g:ledger_main)) . ' payees'),
414-
\ "v:val =~? '" . strpart(a:argLead, 1) . "'"), '"@" . escape(v:val, " ")')
414+
\ "v:val =~? '" . strpart(a:argLead, 1) . "' && v:val !~? '^Warning: '"), '"@" . escape(v:val, " ")')
415415
\ :
416416
\ map(filter(systemlist(g:ledger_bin . ' -f ' . shellescape(expand(g:ledger_main)) . ' accounts'),
417-
\ "v:val =~? '" . a:argLead . "'"), 'escape(v:val, " ")')
417+
\ "v:val =~? '" . a:argLead . "' && v:val !~? '^Warning: '"), 'escape(v:val, " ")')
418418
endf "}}}
419419

420420
function! s:reconcile(account) "{{{2

0 commit comments

Comments
 (0)