[vim/vim] gq indents inline nested html text inappropriately (#8553)

43 views
Skip to first unread message

Mahmoud Al-Qudsi

unread,
Jul 11, 2021, 8:19:48 PM7/11/21
to vim/vim, Subscribed

Describe the bug

When a text selection contains non-tree html (and co) content, the indent file logic goes awry and the result is exceedingly.. unaesthetic.

To Reproduce

Given this document fragment saved as test.html:

<p>Until next time,</p>

<p>The NeoSmart Team</p> <small>You signed up for these emails when you
downloaded one of our free utilities - probably EasyBCD. If you prefer
not to receive this and other computer-related tips, advice, or
information, <a href="[unsubscribe]">please click here to remove
your name and email from our list</a>.</small></div>
</div> </body> </html>

Run vim test.html execute vG followed by gq

The result is the following:

<p>Until next time,</p>

<p>The NeoSmart Team</p> <small>You signed up for these emails when you
	downloaded one of our free utilities - probably EasyBCD. If you prefer not
	to receive this and other computer-related tips, advice, or information, <a
		href="[unsubscribe]">please click here to remove your name and email
		from our list</a>.</small></div> </div> </body> </html>

Expected behavior

HTML tags that are on their own line should have their contents indented by one tabstop, but HTML tags that do not start on their own line (i.e. "inline" html tags) should not receive any indentation on overflow to subsequent lines.

e.g.

<hello>
<friend>
...

should be distinguished from

<hello><friend>
...

Environment (please complete the following information):

  • Vim version 8.0 with patches 1-1453
  • OS: Ubuntu 18.04
  • Terminal: N/A


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

Valeriy Manzhos

unread,
Sep 13, 2021, 2:52:56 AM9/13/21
to vim/vim, Subscribed

Also reproducible for XML, JSON and YAML on
$ vim --version

VIM - Vi IMproved 8.0 (2016 Sep 12)
Included patches: 1-1568
Compiled by 'http://www.opensuse.org/'
Huge version without GUI.  Features included (+) or not (-):
+acl               +farsi             +mouse_sgr         -tag_any_white
+arabic            +file_in_path      -mouse_sysmouse    -tcl
+autocmd           +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal     
-balloon_eval      +folding           +multi_byte        +terminfo     
+balloon_eval_term -footer            +multi_lang        +termresponse 
-browse            +fork()            -mzscheme          +textobjects  
++builtin_terms    +gettext           +netbeans_intg     +timers
+byte_offset       -hangul_input      +num64             +title
+channel           +iconv             +packages          -toolbar
+cindent           +insert_expand     +path_extra        +user_commands
-clientserver      +job               +perl              +vertsplit
-clipboard         +jumplist          +persistent_undo   +virtualedit
+cmdline_compl     +keymap            +postscript        +visual
+cmdline_hist      +lambda            +printer           +visualextra
+cmdline_info      +langmap           +profile           +viminfo
+comments          +libcall           +python/dyn        +vreplace
+conceal           +linebreak         +python3/dyn       +wildignore
+cryptv            +lispindent        +quickfix          +wildmenu
+cscope            +listcmds          +reltime           +windows
+cursorbind        +localmap          +rightleft         +writebackup
+cursorshape       +lua/dyn           +ruby/dyn          -X11
+dialog_con        +menu              +scrollbind        -xfontset
+diff              +mksession         +signs             -xim
+digraphs          +modify_fname      +smartindent       -xpm
-dnd               +mouse             +startuptime       -xsmp
-ebcdic            -mouseshape        +statusline        -xterm_clipboard
+emacs_tags        +mouse_dec         -sun_workshop      -xterm_save
+eval              -mouse_gpm         +syntax
+ex_extra          -mouse_jsbterm     +tag_binary
+extra_search      +mouse_netterm     +tag_old_static
   system vimrc file: "/etc/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     -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -Wall 
-pipe -fno-strict-aliasing -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L. -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.26.1/x86_64-linux-thread-multi/CORE   -L/usr/local/lib -Wl,--as-needed -o vim        -lm  -lselinux   -ltinfo -lacl -lattr -ldl   -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.26.1/x86_64-linux-thread-multi/CORE  -L/usr/local/lib64 -fstack-protector-strong  -L/usr/lib/perl5/5.26.1/x86_64-linux-thread-multi/CORE -lperl -lm -ldl -lcrypt -lpthread

but not on CentOS 6

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jul 16 2019 20:50:52)
Included patches: 1-207, 209-629
Modified by <bugz...@redhat.com>
Compiled by <bugz...@redhat.com>
Huge version without GUI.  Features included (+) or not (-):
+acl             +farsi           +mouse_netterm   +syntax
+arabic          +file_in_path    +mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
-balloon_eval    +float           +mouse_urxvt     -tag_any_white
-browse          +folding         +mouse_xterm     -tcl
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         +gettext         -mzscheme        +textobjects
-clientserver    -hangul_input    +netbeans_intg   +title
-clipboard       +iconv           +path_extra      -toolbar
+cmdline_compl   +insert_expand   +perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python/dyn      +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con      -lua             +rightleft       +windows
+diff            +menu            -ruby            +writebackup
+digraphs        +mksession       +scrollbind      -X11
-dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     -xim
+emacs_tags      -mouseshape      -sniff           -xsmp
+eval            +mouse_dec       +startuptime     -xterm_clipboard
+ex_extra        +mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    -xpm
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/etc"
 f-b for $VIMRUNTIME: "/usr/share/vim/vim74"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -g -pipe -Wall -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -Wl,-E -Wl,-rpath,/usr/lib64/perl5/CORE   -L/usr/local/lib -Wl,--as-needed -o vim        -lm -lnsl  -lselinux  -ltinfo -lacl -lattr -lgpm   -Wl,-E -Wl,-rpath,/usr/lib64/perl5/CORE  -fstack-protector  -L/usr/lib64/perl5/CORE -lperl -lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc

hope that helps to trace the problem


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

Mahmoud Al-Qudsi

unread,
Dec 17, 2021, 5:03:17 PM12/17/21
to vim/vim, Subscribed

It bisects to 690afe1 which touched both runtime/syntax/html.vim and runtime/indent/html.vim but not in a way that makes it immediately clear (to me) what the actual problem is.


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

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

Mahmoud Al-Qudsi

unread,
Dec 17, 2021, 5:07:38 PM12/17/21
to vim/vim, Subscribed

Is it the removal of cino<" from b:undo_intent?


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

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

lacygoill

unread,
Dec 17, 2021, 10:33:57 PM12/17/21
to vim/vim, Subscribed

along with a million other files

17 other files.

Is it the removal of cino<" from b:undo_intent?

No, the behavior changed because the javascript indent plugin was sourced:

runtime! indent/javascript.vim

The latter set 'autoindent':

setlocal autoindent nolisp nosmartindent
^-----------------^

At the time, it seems that resetting the option was enough to restore the old indent:

setlocal noautoindent
         ^^

But since 8.2.3615, it is no longer enough to restore the old indent. I don't know why.


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

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

lacygoill

unread,
Dec 17, 2021, 11:12:59 PM12/17/21
to vim/vim, Subscribed

For anyone who wants to try to debug this:

vim -Nu NONE --cmd 'filetype indent on | syntax on' +'set noautoindent | breakadd func HtmlIndent' test.html

At the debugging prompt, execute echo v:lnum to read the address of the line for which HtmlIndent() is computing the indent. If it's the address of a line for which you know that the indent will be correct, skip the function call by executing cont. Otherwise, execute next (or step to step into another function call).


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

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

Reply all
Reply to author
Forward
0 new messages