[vim/vim] Inconsistent behavior opening/closing folds (Issue #10436)

16 views
Skip to first unread message

Andrey Mishchenko

unread,
May 16, 2022, 8:44:23 PM5/16/22
to vim/vim, Subscribed

Steps to reproduce

  1. vim --clean
  2. ia<CR><Tab>b<Esc>
  3. zc, zo → nothing happens, apparently can't fold/unfold one line
  • Note that the indent-based fold is there, and is visible if you set foldcolumn=4
  1. o<Tab>c<Esc>
  2. The screen now reads:
    a
    
        b
    
        c
    
    
  3. zc, zo → fold closes and opens
  4. dd
  5. zc, zo → one-line fold now closes and opens!

Expected behaviour

I would expect that either (1) you can always open and close one-line folds, or (2) you can never open and close one-line folds.

Version of Vim

Latest, built from source.

Environment

macOS 12

Logs and stack traces

No response


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/10436@github.com>

Christian Brabandt

unread,
May 17, 2022, 2:16:11 AM5/17/22
to vim/vim, Subscribed

I cannot reproduce with neither 8.2.4969 on linux or windows (gvim)


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/10436/1128456129@github.com>

Andrey Mishchenko

unread,
May 17, 2022, 9:17:39 AM5/17/22
to vim/vim, Subscribed

This reproduces for me on Linux, and also reproduces in Neovim. Here is a GIF of it happening in the following Linux env:

Screen Recording 2022-05-17 at 7 14 47 AM

root@scratch:~# vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Feb 01 2022 09:16:32)
Included patches: 1-2269, 3612, 3625, 3669, 3741
Modified by team...@tracker.debian.org
Compiled by team...@tracker.debian.org
Huge version without GUI.  Features included (+) or not (-):
+acl               -farsi             -mouse_sysmouse    -tag_any_white
+arabic            +file_in_path      +mouse_urxvt       -tcl
+autocmd           +find_in_path      +mouse_xterm       +termguicolors
+autochdir         +float             +multi_byte        +terminal
-autoservername    +folding           +multi_lang        +terminfo
-balloon_eval      -footer            -mzscheme          +termresponse
+balloon_eval_term +fork()            +netbeans_intg     +textobjects
-browse            +gettext           +num64             +textprop
++builtin_terms    -hangul_input      +packages          +timers
+byte_offset       +iconv             +path_extra        +title
+channel           +insert_expand     -perl              -toolbar
+cindent           +job               +persistent_undo   +user_commands
-clientserver      +jumplist          +postscript        +vartabs
-clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +virtualedit
+cmdline_hist      +langmap           -python            +visual
+cmdline_info      +libcall           +python3           +visualextra
+comments          +linebreak         +quickfix          +viminfo
+conceal           +lispindent        +reltime           +vreplace
+cryptv            +listcmds          +rightleft         +wildignore
+cscope            +localmap          -ruby              +wildmenu
+cursorbind        -lua               +scrollbind        +windows
+cursorshape       +menu              +signs             +writebackup
+dialog_con        +mksession         +smartindent       -X11
+diff              +modify_fname      +sound             -xfontset
+digraphs          +mouse             +spell             -xim
-dnd               -mouseshape        +startuptime       -xpm
-ebcdic            +mouse_dec         +statusline        -xsmp
+emacs_tags        +mouse_gpm         -sun_workshop      -xterm_clipboard
+eval              -mouse_jsbterm     +syntax            -xterm_save
+ex_extra          +mouse_netterm     +tag_binary
+extra_search      +mouse_sgr         -tag_old_static
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -Wdate-time  -g -O2 -fdebug-prefix-map=/build/vim-9EpYYi/vim-8.1.2269=. -fstack-protector-strong -Wformat -Werror=format-security -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux  -lcanberra -lacl -lattr -lgpm -ldl     -L/usr/lib/python3.8/config-3.8-x86_64-linux-gnu -lpython3.8 -lcrypt -lpthread -ldl -lutil -lm -lm
root@scratch:~# uname -a
Linux scratch 5.4.0-97-generic #110-Ubuntu SMP Thu Jan 13 18:22:13 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
root@scratch:~#


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/10436/1128858183@github.com>

Andrey Mishchenko

unread,
May 17, 2022, 9:18:45 AM5/17/22
to vim/vim, Subscribed

Very sorry, I forgot a repro step: :set foldmethod=indent. The original issue has been updated. @chrisbra


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/10436/1128859391@github.com>

Christian Brabandt

unread,
May 17, 2022, 1:46:56 PM5/17/22
to vim/vim, Subscribed

Hm, I think partially what you see can be explained by :h 'foldminlines' Also please note the following section (which I am not sure I understand completely but it may explain what you notice):

Set to zero to be able to close folds of just one screen line.
Note that this only has an effect on what is displayed.  After using
"zc" to close a fold, which is displayed open because it's smaller
than 'foldminlines', a following "zc" may close a containing fold.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/10436/1129148045@github.com>

Andrey Mishchenko

unread,
May 19, 2022, 4:01:41 PM5/19/22
to vim/vim, Subscribed

I guess foldminlines is a related setting, but I would say this screenshot (following my repro steps) demonstrates a bug, demonstrating foldminlines not being respected.
image


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/10436/1132142999@github.com>

Brandon Simmons

unread,
May 20, 2022, 12:33:04 PM5/20/22
to vim/vim, Subscribed

Hm, I think partially what you see can be explained by :h 'foldminlines' Also please note the following section (which I am not sure I understand completely but it may explain what you notice):

Set to zero to be able to close folds of just one screen line.
Note that this only has an effect on what is displayed.  After using
"zc" to close a fold, which is displayed open because it's smaller
than 'foldminlines', a following "zc" may close a containing fold.

This means that the commands you type, like "zc", still do their action on the small fold even if it doesn't visually look like it happened. For example, if you had a one line fold nested within a, say, 5 line fold, and all the folds were open, then if you put your cursor on the one line fold and press "zc", then the fold would "close" even though nothing would change on your screen. Then hitting "zc" again would close the big outer fold and you'd see the lines fold on your screen.

The bug was that the opposite would actually happen -- that when you close a small (less than foldminlines) fold after a deletion, it would actually fold on your screen, meaning that foldminlines didn't do its job.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/10436/1133102141@github.com>

Andrey Mishchenko

unread,
May 22, 2022, 3:05:05 PM5/22/22
to vim/vim, Subscribed

I can confirm that this is fixed after #10457.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/10436/1133954780@github.com>

Andrey Mishchenko

unread,
May 22, 2022, 3:05:07 PM5/22/22
to vim/vim, Subscribed

Closed #10436 as completed.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/10436/issue_event/6656527704@github.com>

Bram Moolenaar

unread,
Oct 11, 2022, 5:18:43 AM10/11/22
to vim/vim, Subscribed


> ### Steps to reproduce
>
> 1. `vim --clean`

I assume you set 'foldmethod' to "indent" here.

> 2. `ia<CR><Tab>b<Esc>`
> 3. `zc`, `zo` → nothing happens, apparently can't fold/unfold one line
> * Note that the indent-based fold *is* there, and is visible if you
> `set foldcolumn=4`
> 4. `o<Tab>c<Esc>`
> 5. The screen now reads:
> ```
> a
> b
> c
> ```
> 6. `zc`, `zo` → fold closes and opens
> 7. `dd`
> 8. `zc`, `zo` → one-line fold now closes and opens!
>
> ### Expected behaviour

>
> I would expect that either (1) you can always open and close one-line folds, or (2) you can never open and close one-line folds.

The idea is tha folding one line doesn't make much sense. That you can
close a one-line fold looks like a bug. Probably when deleting the line
some fold information is not updated.

Some users have argued that there is use in closing a one-line fold,
especially when the 'foldtext' is used.

So we could fix it by also allowing to close a one-line fold.

--
Don't be humble ... you're not that great.
-- Golda Meir

/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/10436/1274382238@github.com>

Reply all
Reply to author
Forward
0 new messages