On 1 May 2015, Rich <[email protected]> wrote:
> Hi
>
> You don't need to use any plugin to test this.
>
> If you want proof that foldexpr is used for autocomplete, try this:
>
> let g:c = 0
> function! Myfoldexpr()
> let g:c = 1 + g:c
> return '='
> endfunction
>
> Then make a file with 10 lines.
> :set fdm=expr
> :set foldexpr=Myfoldexpr()
> :echo g:c
>
> It will say 11.
> zx
> :echo g:c
> it will say 22
>
> Now edit a new line and press <C-X>L
> :echo g:c
> it now says 33 or 34
>
> Now if you make a file with 100 lines in it, each with a single
> character. press <C-X>L and have a look at the counter, it's up to
> nearer 150.
>
> Now the fun part. Make your file 100 lines long, each with 10
> characters in it.Start a new line and <C-X>L then escape and look at
> the counter. Mine's at 7,437 executions!
[...]
Right, it's actually worse than that: the entire folding is
redone at every key press. :) If you feel particularly adventurous
and you aren't easily upset by tiny details like segfaults, you might
try the patch below. It's a naive attempt to alleviate the problem
for autocomplete. It's definitely not the right fix. But I don't
understand the code well enough to come up with a better one, so I'll
leave finding the real solution to the grown-ups.
/lcd
diff --git a/src/edit.c b/src/edit.c
--- a/src/edit.c
+++ b/src/edit.c
@@ -673,12 +673,15 @@
#endif
#ifdef FEAT_FOLDING
- /* Open fold at the cursor line, according to 'foldopen'. */
- if (fdo_flags & FDO_INSERT)
- foldOpenCursor();
- /* Close folds where the cursor isn't, according to 'foldclose' */
- if (!char_avail())
- foldCheckClose();
+ if (!compl_started || !pum_wanted())
+ {
+ /* Open fold at the cursor line, according to 'foldopen'. */
+ if (fdo_flags & FDO_INSERT)
+ foldOpenCursor();
+ /* Close folds where the cursor isn't, according to 'foldclose' */
+ if (!char_avail())
+ foldCheckClose();
+ }
#endif
/*
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.