[html] Fix indentation when entering a newline while in the middle of a tag

Example:

```
        <tag>|</tag>
```
Then press enter

Old behaviour:
```
        <tag>
            </tag>
```
New behaviour:
```
        <tag>
        </tag>
```

I also added a test for it
This commit is contained in:
Jan-Jaap Korpershoek 2019-11-03 12:12:11 +01:00
parent ec31d83972
commit fcc8ed5df3
5 changed files with 13 additions and 2 deletions

View File

@ -80,8 +80,8 @@ define-command -hidden html-indent-on-new-line %{
try %{ execute-keys -draft <semicolon> K <a-&> } try %{ execute-keys -draft <semicolon> K <a-&> }
# filter previous line # filter previous line
try %{ execute-keys -draft k : html-trim-indent <ret> } try %{ execute-keys -draft k : html-trim-indent <ret> }
# indent after lines ending with opening tag # indent after lines ending with opening tag except when it starts with a closing tag
try %{ execute-keys -draft k <a-x> <a-k> <lt>(?!area)(?!base)(?!br)(?!col)(?!command)(?!embed)(?!hr)(?!img)(?!input)(?!keygen)(?!link)(?!menuitem)(?!meta)(?!param)(?!source)(?!track)(?!wbr)(?!/)(?!>)[a-zA-Z0-9_-]+[^>]*?>$ <ret> j <a-gt> } } try %{ execute-keys -draft k <a-x> <a-k> <lt>(?!area)(?!base)(?!br)(?!col)(?!command)(?!embed)(?!hr)(?!img)(?!input)(?!keygen)(?!link)(?!menuitem)(?!meta)(?!param)(?!source)(?!track)(?!wbr)(?!/)(?!>)[a-zA-Z0-9_-]+[^>]*?>$ <ret>j<a-x><a-K>^\s*<lt>/<ret><a-gt> } }
} }
] ]

View File

@ -0,0 +1 @@
i<ret><esc>

View File

@ -0,0 +1,3 @@
<div>
<div>%( )</div>
</div>

View File

@ -0,0 +1,4 @@
<div>
<div>
</div>
</div>

View File

@ -0,0 +1,3 @@
source "%val{runtime}/colors/default.kak"
source "%val{runtime}/rc/filetype/html.kak"
set buffer filetype html