From ef1f1907cc4f9c74fc415d7411aacf8c61a4a38f Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 29 Jul 2019 02:59:32 +0200 Subject: vim-patch:4c05fa08c973 Update runtime files https://github.com/vim/vim/commit/4c05fa08c9739e307ddc88ac91ba6d208f1fd68e --- runtime/autoload/RstFold.vim | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/RstFold.vim b/runtime/autoload/RstFold.vim index 5becb04685..238b1e3537 100644 --- a/runtime/autoload/RstFold.vim +++ b/runtime/autoload/RstFold.vim @@ -1,8 +1,12 @@ " Author: Antony Lee " Description: Helper functions for reStructuredText syntax folding -" Last Modified: 2018-01-07 +" Last Modified: 2018-12-29 function s:CacheRstFold() + if !g:rst_fold_enabled + return + endif + let closure = {'header_types': {}, 'max_level': 0, 'levels': {}} function closure.Process(match) dict let curline = getcurpos()[1] @@ -20,12 +24,18 @@ function s:CacheRstFold() let self.levels[curline] = self.header_types[key] endfunction let save_cursor = getcurpos() + let save_mark = getpos("'[") silent keeppatterns %s/\v^%(%(([=`:.'"~^_*+#-])\1+\n)?.{1,2}\n([=`:.'"~^_*+#-])\2+)|%(%(([=`:.''"~^_*+#-])\3{2,}\n)?.{3,}\n([=`:.''"~^_*+#-])\4{2,})$/\=closure.Process(submatch(0))/gn call setpos('.', save_cursor) + call setpos("'[", save_mark) let b:RstFoldCache = closure.levels endfunction function RstFold#GetRstFold() + if !g:rst_fold_enabled + return + endif + if !has_key(b:, 'RstFoldCache') call s:CacheRstFold() endif @@ -37,6 +47,10 @@ function RstFold#GetRstFold() endfunction function RstFold#GetRstFoldText() + if !g:rst_fold_enabled + return + endif + if !has_key(b:, 'RstFoldCache') call s:CacheRstFold() endif -- cgit