From 83b6a18598a76730d546beebb1951054611344e5 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 1 May 2021 19:15:16 -0400 Subject: vim-patch:23515b4ef758 Update runtime files https://github.com/vim/vim/commit/23515b4ef7580af8b9d3b964a558ab2007cacda5 Omit filetype.txt changes for :Man. --- runtime/indent/xml.vim | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'runtime/indent/xml.vim') diff --git a/runtime/indent/xml.vim b/runtime/indent/xml.vim index 413a3ddb53..da65417939 100644 --- a/runtime/indent/xml.vim +++ b/runtime/indent/xml.vim @@ -2,8 +2,9 @@ " Maintainer: Christian Brabandt " Repository: https://github.com/chrisbra/vim-xml-ftplugin " Previous Maintainer: Johannes Zellner -" Last Changed: 2019 Dec 02 +" Last Changed: 2020 Nov 4th " Last Change: +" 20200529 - Handle empty closing tags correctly " 20191202 - Handle docbk filetype " 20190726 - Correctly handle non-tagged data " 20190204 - correctly handle wrap tags @@ -45,7 +46,7 @@ if !exists('b:xml_indent_open') endif if !exists('b:xml_indent_close') - let b:xml_indent_close = '.\{-}.\{-}' " end pre tag, e.g. " let b:xml_indent_close = '.\{-}XmlIndentSum(line, style, add) - if IsXMLContinuation(a:line) && a:style == 0 + if IsXMLContinuation(a:line) && a:style == 0 && !IsXMLEmptyClosingTag(a:line) " no complete tag, add one additional indent level " but only for the current line return a:add + shiftwidth() @@ -131,13 +132,25 @@ fun! XmlIndentGet(lnum, use_syntax_check) endif let syn_name_end = synIDattr(synID(a:lnum, strlen(curline) - 1, 1), 'name') let syn_name_start = synIDattr(synID(a:lnum, match(curline, '\S') + 1, 1), 'name') + let prev_syn_name_end = synIDattr(synID(ptag, strlen(pline) - 1, 1), 'name') + " not needed (yet?) + " let prev_syn_name_start = synIDattr(synID(ptag, match(pline, '\S') + 1, 1), 'name') endif if syn_name_end =~ 'Comment' && syn_name_start =~ 'Comment' return XmlIndentComment(a:lnum) elseif empty(syn_name_start) && empty(syn_name_end) && a:use_syntax_check " non-xml tag content: use indent from 'autoindent' - return pind + shiftwidth() + if pline =~ b:xml_indent_close + return pind + elseif !empty(prev_syn_name_end) + " only indent by an extra shiftwidth, if the previous line ends + " with an XML like tag + return pind + shiftwidth() + else + " no extra indent, looks like a text continuation line + return pind + endif endif " Get indent from previous tag line @@ -157,15 +170,28 @@ func! HasNoTagEnd(line) return a:line !~ '>\s*$' endfunc +func! IsXMLEmptyClosingTag(line) + " Checks whether the line ends with an empty closing tag such as + return a:line =~? '<[^>]*/>\s*$' +endfunc + " return indent for a commented line, " the middle part might be indented one additional level func! XmlIndentComment(lnum) - let ptagopen = search(b:xml_indent_open, 'bnW') + let ptagopen = search('.\{-}<[:A-Z_a-z]\_[^/]\{-}>.\{-}', 'bnW') let ptagclose = search(b:xml_indent_close, 'bnW') if getline(a:lnum) =~ '