On 2017-12-13, Gary Johnson wrote:
> On 2017-12-13, 'Andy Wokula' via vim_dev wrote:
> > Am 13.12.2017 um 18:57 schrieb Gary Johnson:
> > >I've had a bug in one of my plugins that I finally traced to what
> > >appears to be a bug in Vim (8.0.1257): a substitution on one line
> > >of a closed fold affects all lines in that fold.
>
> > Works as documented:
> > :h fold-behavior
> >
> > For Ex commands that work on buffer lines the range is adjusted to always
> > start at the first line of a closed fold and end at the last line of a
> > closed
> > fold. Thus this command: >
> > :s/foo/bar/g
> > when used with the cursor on a closed fold, will replace "foo" with "bar" in
> > all lines of the fold.
> >
> > Also try simpler commands like
> > :#
> > :.#
> > on a closed fold.
>
> Thank you. I guess I'll change my plugin to open the fold before
> performing the substitution.
To follow up, here is what I did to fix the problematic function in
my plugin. I added code above and below this line, which had been
modifying every line in a closed fold instead of just l:lnum,
silent exe l:lnum.'s/:.*/:\t'.strftime("%Y-%m-%d %H:%M:%S").'/'
to open any closed fold at that line and, if necessary, re-close it.
let l:foldclosed = foldclosed(l:lnum) > 0
if l:foldclosed
exe l:lnum."foldopen"
endif
silent exe l:lnum.'s/:.*/:\t'.strftime("%Y-%m-%d %H:%M:%S").'/'
if l:foldclosed
exe l:lnum."foldclose"
endif
Regards,
Gary
--
--
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.