tyru / caw.vim

Vim comment plugin: supported operator/non-operator mappings, repeatable by dot-command, 300+ filetypes
379 stars 48 forks source link

Indentation loss on XML elements #94

Closed herrbischoff closed 4 years ago

herrbischoff commented 5 years ago

Environment

NVIM v0.3.1
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/tmp/neovim-20181019-50893-1j0fv9i/neovim-0.3.1/build/config -I/tmp/neovim-20181019-50893-1j0fv9i/neovim-0.3.1/src -I/usr/local/include -I/usr/local/opt/gettext/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/tmp/neovim-20181019-50893-1j0fv9i/neovim-0.3.1/build/src/nvim/auto -I/tmp/neovim-20181019-50893-1j0fv9i/neovim-0.3.1/build/include
Compiled by brew@Mojave-2.local

Features: +acl +iconv +jemalloc +tui 
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.3.1/share/nvim"

Run :checkhealth for more info

Issue

When uncommenting XML/HTML elements, caw does not restore the previous (and preserved in commented state) indentation but instead pulls all attributes to the root indent level. This cannot be expected behavior.

Additionally, wrapping comment tags appear to require the use of gcw and gcuw which I feel is rather clumsy. I'd expect gcc with selected lines to do the same. However, with JSP files for example, this does not even attempt to comment correctly but just uses the C default // instead. It took me quite a while to figure out why.

Example

The commenting below is within JSP files. However, even an HTML filetype does not change this behavior.

Original

 <div>
  <picture>
    <source
      media="(min-width: 1200px)"
      srcset="img.png, img.png@2x 2x"
    />
    <img src="img.png" alt="image" class="image" />
  </picture>
</div>

Commented

<%-- <div>                                               --%>
<%--   <picture>                                         --%>
<%--     <source                                         --%>
<%--       media="(min-width: 1200px)"                   --%>
<%--       srcset="img.png, img.png@2x 2x"               --%>
<%--     />                                              --%>
<%--     <img src="img.png" alt="image" class="image" /> --%>
<%--   </picture>                                        --%>
<%-- </div>                                              --%>

Uncommented

<div>
<picture>
<source
media="(min-width: 1200px)"
srcset="img.png, img.png@2x 2x"
/>
<img src="img.png" alt="image" class="image" />
</picture>
</div>
tyru commented 4 years ago

@herrbischoff could you try #115 ?

tyru commented 4 years ago

sorry, merged to devel branch. please try this on the branch.

tyru commented 4 years ago

Fixed in #118

herrbischoff commented 4 years ago

Thanks, I didn’t have time yet to check this out. Will do so shortly and provide feedback.