targets.vim icon indicating copy to clipboard operation
targets.vim copied to clipboard

Problem with modeline `vim: foldmethod=marker foldlevel=0`

Open QzCurious opened this issue 5 years ago • 4 comments

What the problem is about

Start vim file with modeline vim: foldmethod=marker foldlevel=0. First try of command like da< or da[ delete a fold (precisely, it leaves a blank line).

Steps to re-produce the problem:

  1. vimrc
call plug#begin('~/.vim/plugged')
Plug 'wellle/targets.vim'
call plug#end()
  1. $ vim textfile.html (see below)
  2. textfile.html with modeline
<!-- {{{ -->
<div>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum dolor sit amet.
</div>
<!-- }}} -->

<!--
    vim: foldmethod=marker foldlevel=0
-->
  1. Type da< or da[ inside the fold
  2. Problem occur

What I've tried

It won't happen if I remove modeline and manually set the options after I enter vim. Proceeding commands like da< works fine.

QzCurious avatar Jun 10 '19 20:06 QzCurious

Can confirm that it doesn't work with folds. Thanks for the heads up 👍

Not quite sure yet how to fix that.

wellle avatar Jun 11 '19 21:06 wellle

Cost me some time to get the same conclusion, seems targets.vim is not compatible with folds. It just doesn't work the 1st time using targets mapping in a folded block. I could reproduce the bug with va" and following content

#!/usr/bin/env bash
# vim: fdm=marker fdl=0
# test {{{
echo "111"
echo "222"
echo "333"
# }}}

Any idea to bypass the problem?

Sometimes, it even deletes the content accidentally.

laggardkernel avatar Aug 15 '21 06:08 laggardkernel

Just found a way to bypass the problem.

" Put it into init.vim
call targets#sources#newFactories('')

I haven't digger it deeper why it works. My guess is some of the functions in targets.vim are lazy-loaded and the loading of these functions triggers this very fold related problem. The above call is just pre-loading some of the functions manually.

laggardkernel avatar Sep 12 '21 12:09 laggardkernel

I'm sorry that I don't use vim for very long time. Can't help with this discussion further.

Should I close this? Or maybe it were already fix?

QzCurious avatar May 26 '23 07:05 QzCurious