From fcc8ed5df3de7f6ac8b56734ad09bcbb9207a48a Mon Sep 17 00:00:00 2001 From: Jan-Jaap Korpershoek Date: Sun, 3 Nov 2019 12:12:11 +0100 Subject: [PATCH] [html] Fix indentation when entering a newline while in the middle of a tag Example: ``` | ``` Then press enter Old behaviour: ``` ``` New behaviour: ``` ``` I also added a test for it --- rc/filetype/html.kak | 4 ++-- test/indent/html/indent-on-new-line/cmd | 1 + test/indent/html/indent-on-new-line/in | 3 +++ test/indent/html/indent-on-new-line/out | 4 ++++ test/indent/html/indent-on-new-line/rc | 3 +++ 5 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 test/indent/html/indent-on-new-line/cmd create mode 100644 test/indent/html/indent-on-new-line/in create mode 100644 test/indent/html/indent-on-new-line/out create mode 100644 test/indent/html/indent-on-new-line/rc diff --git a/rc/filetype/html.kak b/rc/filetype/html.kak index 4a86e21b..33e65a9b 100644 --- a/rc/filetype/html.kak +++ b/rc/filetype/html.kak @@ -80,8 +80,8 @@ define-command -hidden html-indent-on-new-line %{ try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : html-trim-indent } - # indent after lines ending with opening tag - try %{ execute-keys -draft k (?!area)(?!base)(?!br)(?!col)(?!command)(?!embed)(?!hr)(?!img)(?!input)(?!keygen)(?!link)(?!menuitem)(?!meta)(?!param)(?!source)(?!track)(?!wbr)(?!/)(?!>)[a-zA-Z0-9_-]+[^>]*?>$ j } } + # indent after lines ending with opening tag except when it starts with a closing tag + try %{ execute-keys -draft k (?!area)(?!base)(?!br)(?!col)(?!command)(?!embed)(?!hr)(?!img)(?!input)(?!keygen)(?!link)(?!menuitem)(?!meta)(?!param)(?!source)(?!track)(?!wbr)(?!/)(?!>)[a-zA-Z0-9_-]+[^>]*?>$ j^\s*/ } } } ] diff --git a/test/indent/html/indent-on-new-line/cmd b/test/indent/html/indent-on-new-line/cmd new file mode 100644 index 00000000..54aed4f8 --- /dev/null +++ b/test/indent/html/indent-on-new-line/cmd @@ -0,0 +1 @@ +i diff --git a/test/indent/html/indent-on-new-line/in b/test/indent/html/indent-on-new-line/in new file mode 100644 index 00000000..45bc08e1 --- /dev/null +++ b/test/indent/html/indent-on-new-line/in @@ -0,0 +1,3 @@ +
+
%( )
+
diff --git a/test/indent/html/indent-on-new-line/out b/test/indent/html/indent-on-new-line/out new file mode 100644 index 00000000..914642e9 --- /dev/null +++ b/test/indent/html/indent-on-new-line/out @@ -0,0 +1,4 @@ +
+
+
+
diff --git a/test/indent/html/indent-on-new-line/rc b/test/indent/html/indent-on-new-line/rc new file mode 100644 index 00000000..ef3301f7 --- /dev/null +++ b/test/indent/html/indent-on-new-line/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/filetype/html.kak" +set buffer filetype html