[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:
parent
ec31d83972
commit
fcc8ed5df3
|
@ -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> } }
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
1
test/indent/html/indent-on-new-line/cmd
Normal file
1
test/indent/html/indent-on-new-line/cmd
Normal file
|
@ -0,0 +1 @@
|
||||||
|
i<ret><esc>
|
3
test/indent/html/indent-on-new-line/in
Normal file
3
test/indent/html/indent-on-new-line/in
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<div>
|
||||||
|
<div>%( )</div>
|
||||||
|
</div>
|
4
test/indent/html/indent-on-new-line/out
Normal file
4
test/indent/html/indent-on-new-line/out
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
</div>
|
||||||
|
</div>
|
3
test/indent/html/indent-on-new-line/rc
Normal file
3
test/indent/html/indent-on-new-line/rc
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
source "%val{runtime}/colors/default.kak"
|
||||||
|
source "%val{runtime}/rc/filetype/html.kak"
|
||||||
|
set buffer filetype html
|
Loading…
Reference in New Issue
Block a user