From 58561ed511753c4ef0fd446010daa1c2b7979d42 Mon Sep 17 00:00:00 2001 From: Jonathan Dowland <63694+jmtd@users.noreply.github.com> Date: Thu, 2 May 2024 09:44:26 +0100 Subject: [PATCH] fix(foldtext): Match (and ignore) balance assertions on postings (#154) --- ftplugin/ledger.vim | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ftplugin/ledger.vim b/ftplugin/ledger.vim index d65ab51..10ce8af 100644 --- a/ftplugin/ledger.vim +++ b/ftplugin/ledger.vim @@ -215,13 +215,18 @@ hi link LedgerTarget Statement hi link LedgerImproperPerc Special " }}} -let s:rx_amount = '\('. - \ '\%([0-9]\+\)'. - \ '\%([,.][0-9]\+\)*'. - \ '\|'. - \ '[,.][0-9]\+'. - \ '\)'. - \ '\s*\%([[:alpha:]¢$€£]\+\s*\)\?'. +let s:cursym = '[[:alpha:]¢$€£]\+' +let s:valreg = '\('. + \ '\%([0-9]\+\)'. + \ '\%([,.][0-9]\+\)*'. + \ '\|'. + \ '[,.][0-9]\+'. + \ '\)' +let s:optional_balance_assertion = '\(\s*=\s*'.s:cursym.'\s*'.s:valreg.'\)\?' + +let s:rx_amount = s:valreg. + \ s:optional_balance_assertion. + \ '\s*\%('.s:cursym.'\s*\)\?'. \ '\%(\s*;.*\)\?$' function! LedgerFoldText() "{{{1