[vim/vim] YAML indenting incorrectly (#6417)

830 views
Skip to first unread message

Matt Bell

unread,
Jul 8, 2020, 8:21:49 AM7/8/20
to vim/vim, Subscribed

Describe the bug
When using autoindent with YAML files, vim will try to indent new lines one level too far.

To Reproduce

  1. vim --clean /tmp/foo.yaml
  2. :set autoindent ts=2 sts=2 sw=2 expandtab
  3. insert foo: bar and then enter a new line
  4. two spaces are incorrectly added to the beginning of newline before the cursor

Expected behavior
Indentation level should be 0

Screenshots
image

Environment (please complete the following information):

  • Vim version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jul  8 2020 13:00:55)
macOS version
Included patches: 1-1153
Compiled by ma...@Matthews-MacBook-Pro.local
Huge version without GUI.  Features included (+) or not (-):
+acl               -farsi             +mouse_sgr         +tag_binary
+arabic            +file_in_path      -mouse_sysmouse    -tag_old_static
+autocmd           +find_in_path      +mouse_urxvt       -tag_any_white
+autochdir         +float             +mouse_xterm       -tcl
-autoservername    +folding           +multi_byte        +termguicolors
-balloon_eval      -footer            +multi_lang        +terminal
+balloon_eval_term +fork()            -mzscheme          +terminfo
-browse            +gettext           +netbeans_intg     +termresponse
++builtin_terms    -hangul_input      +num64             +textobjects
+byte_offset       +iconv             +packages          +textprop
+channel           +insert_expand     +path_extra        +timers
+cindent           +ipv6              +perl              +title
-clientserver      +job               +persistent_undo   -toolbar
+clipboard         +jumplist          +popupwin          +user_commands
+cmdline_compl     +keymap            +postscript        +vartabs
+cmdline_hist      +lambda            +printer           +vertsplit
+cmdline_info      +langmap           +profile           +virtualedit
+comments          +libcall           -python            +visual
+conceal           +linebreak         +python3           +visualextra
+cryptv            +lispindent        +quickfix          +viminfo
+cscope            +listcmds          +reltime           +vreplace
+cursorbind        +localmap          +rightleft         +wildignore
+cursorshape       +lua               +ruby              +wildmenu
+dialog_con        +menu              +scrollbind        +windows
+diff              +mksession         +signs             +writebackup
+digraphs          +modify_fname      +smartindent       -X11
-dnd               +mouse             -sound             -xfontset
-ebcdic            -mouseshape        +spell             -xim
+emacs_tags        +mouse_dec         +startuptime       -xpm
+eval              -mouse_gpm         +statusline        -xsmp
+ex_extra          -mouse_jsbterm     -sun_workshop      -xterm_clipboard
+extra_search      +mouse_netterm     +syntax            -xterm_save
   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: "/Users/matt/bin/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -I/usr/local/opt/curl-openssl/include -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/zlib/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/curl-openssl/lib -L/usr/local/lib -o vim        -lncurses -liconv -lintl -framework AppKit  -L/usr/local/Cellar/lua/5.3.5_1//lib -llua5.3 -mmacosx-version-min=10.15 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.32.0/lib/perl5/5.32.0/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc  -L/Users/matt/.pyenv/versions/3.8.2/lib/python3.8/config-3.8-darwin -lpython3.8 -framework CoreFoundation  -lruby.2.6
  • OS: macOS 10.15.5 Catalina
  • Terminal: iTerm 2

Additional context
I've experienced this issue with the homebrew-provided vim binary, as well as building directly from master. however I compiled v8.2.0928 from source and didn't experience the issue. so I think there might be a regression in the GetYAMLIndent function. I would be happy to try and debug further but I know very little about vimscript, sorry! :D


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Christian Brabandt

unread,
Jul 8, 2020, 8:27:59 AM7/8/20
to vim/vim, Subscribed

Probably commit acc2240#diff-79d61bef04e12397c4a5d0494a590d30 is too blame, as the other one that touches indent/yaml.vim is 2e693a8#diff-79d61bef04e12397c4a5d0494a590d30 and that one was around 8.1.1165 (where you did not experience this regression).

Matt Bell

unread,
Jul 8, 2020, 8:55:49 AM7/8/20
to vim/vim, Subscribed

Probably commit acc2240#diff-79d61bef04e12397c4a5d0494a590d30 is too blame, as the other one that touches indent/yaml.vim is 2e693a8#diff-79d61bef04e12397c4a5d0494a590d30 and that one was around 8.1.2165 (where you did not experience this regression).

I did a git bisect run and got the same commit as a result:

λ git bisect bad

acc224064033e5cea21ef7f1eefb356ca06ff11d is the first bad commit

commit acc224064033e5cea21ef7f1eefb356ca06ff11d

Matt Bell

unread,
Jul 8, 2020, 9:00:06 AM7/8/20
to vim/vim, Subscribed

actually, I think this is a user error on my part...

acc2240#diff-9f5c7c9c16885cbb1f24528fac00f257

the indent functionality has changed a bit to allow for multiline values. when you add a new line, it's indented, but then after you type a yaml key followed by : it will remove the indent.

example, before:
image

after:

image

I'll close this, sorry for the noise!

Matt Bell

unread,
Jul 8, 2020, 9:00:07 AM7/8/20
to vim/vim, Subscribed

Closed #6417.

Adam Stankiewicz

unread,
Sep 6, 2020, 6:48:18 AM9/6/20
to vim/vim, Subscribed

I think this is very not intuitive behavior... Most keys in yaml are usually not multiline and this makes indentation to temporarily happen each time new key is added. I think indent for multiline text should be explicit by user

Reply all
Reply to author
Forward
0 new messages