diff runtime/indent/xml.vim @ 15729:fe57e4f0eac1

Update runtime files. commit https://github.com/vim/vim/commit/314dd79cac2adc10304212d1980d23ecf6782cfc Author: Bram Moolenaar <Bram@vim.org> Date: Sun Feb 3 15:27:20 2019 +0100 Update runtime files.
author Bram Moolenaar <Bram@vim.org>
date Sun, 03 Feb 2019 15:30:09 +0100
parents 8b334e4cb97f
children bd7461db24b3
line wrap: on
line diff
--- a/runtime/indent/xml.vim
+++ b/runtime/indent/xml.vim
@@ -1,9 +1,11 @@
 "     Language: xml
 "   Repository: https://github.com/chrisbra/vim-xml-ftplugin
-" Last Changed: Dec 07th, 2018
+" Last Changed: Jan 28, 2019
 "   Maintainer: Christian Brabandt <cb@256bit.org>
 " Previous Maintainer:  Johannes Zellner <johannes@zellner.org>
 " Last Change:
+" 20190128 - Make sure to find previous tag
+"            https://github.com/chrisbra/vim-xml-ftplugin/issues/4
 " 20181116 - Fix indentation when tags start with a colon or an underscore
 "            https://github.com/vim/vim/pull/926
 " 20181022 - Do not overwrite indentkeys setting
@@ -88,15 +90,16 @@ endfun
 fun! XmlIndentGet(lnum, use_syntax_check)
     " Find a non-empty line above the current line.
     let plnum = prevnonblank(a:lnum - 1)
-    " Find previous line with a tag (regardless whether open or closed)
-    let ptag = search('.\{-}<[/:A-Z_a-z]', 'bnw')
-
     " Hit the start of the file, use zero indent.
     if plnum == 0
         return 0
     endif
+    " Find previous line with a tag (regardless whether open or closed,
+    " but always start restrict the match to a line before the current one
+    let ptag_pattern = '\%(.\{-}<[/:A-Z_a-z]\)'. '\%(\&\%<'. line('.').'l\)'
+    let ptag = search(ptag_pattern, 'bnw')
+
     let syn_name = ''
-
     if a:use_syntax_check
         let check_lnum = <SID>XmlIndentSynCheck(plnum)
         let check_alnum = <SID>XmlIndentSynCheck(a:lnum)