jwalton512 / vim-blade

Vim syntax highlighting for Blade templates.
225 stars 37 forks source link

HTML closing tag fails to outdent #59

Closed RyanDwyer closed 7 years ago

RyanDwyer commented 7 years ago

Steps to reproduce:

  1. Open a new file with a .blade.php filename.

  2. Enter insert mode and type the following:

    <div><CR></div><CR>
  3. Upon pressing the first <CR>, line 2 (which is empty apart from the cursor) will be indented. This makes sense so far.

  4. Upon pressing the second <CR>, line 2 (now containing an indent + </div>) remains indented. It should be outdented.

Bisected to the following commit:

commit 1e1f2c358b8e1958d322efab669082756e22c304
Author: Adriaan Zonnenberg <amz@adriaan.xyz>
Date:   Tue Jul 5 23:07:17 2016 +0200

    Fix resetting of PHP indentation

    There were a few problems with the PHP indentation resetting to 0.

    - When you pressed return after typing `<?php`:
      Removing `*<Return>` from indentkeys solved this.  When you press
      return now, the next line still gets indented, but the current line
      doesn't get reindented anymore.  I don't think you will need this
      behavior very often so think it is safe to remove.

    - When there was a comment on the first line of a PHP block:
      The indentation on the next line got reset when the first line of a
      PHP block was a comment. Fixed this by skipping `searchpair` if the
      line is a comment.

    I added `0=}},0=!!}` to indentkeys, which reindents the line when you
    type `}}` or `!!}` at the beginning of a line (ignoring whitespace).

Specifically, adding *<Return> back to the indentkeys line fixes it for me.

@adriaanzon Thoughts?

RyanDwyer commented 7 years ago

I discovered this is caused by something else in my config. I had an inoremap </ which effectively runs <C-X><C-O> to autocomplete the tag. This meant the > key is never pressed, which is what the Blade indent file uses to trigger the indent. So it wouldn't trigger the reindent until I hit Enter afterwards, and removing the *<Return> from indentkeys stopped this from working.

adriaanzon commented 7 years ago

FWIW, I think that with the changes from #60, *<Return> can be added back again.