Mercurial > vim
annotate runtime/indent/xml.vim @ 13888:81e8e6181aeb v8.0.1815
patch 8.0.1815: crash with terminal window and with 'lazyredraw' set
commit https://github.com/vim/vim/commit/0cb8ac71ae42f66d525ad855db01361ca38d935a
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri May 11 22:01:51 2018 +0200
patch 8.0.1815: crash with terminal window and with 'lazyredraw' set
Problem: Still a crash with terminal window and with 'lazyredraw' set.
(Antoine)
Solution: Do not wipe out the buffer when updating the screen.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 11 May 2018 22:15:06 +0200 |
parents | 63b0b7b79b25 |
children | 2f7e67dd088c |
rev | line source |
---|---|
7 | 1 " Language: xml |
2 " Maintainer: Johannes Zellner <johannes@zellner.org> | |
11518 | 3 " Last Change: 2017 Jun 13 |
7 | 4 " Notes: 1) does not indent pure non-xml code (e.g. embedded scripts) |
5 " 2) will be confused by unbalanced tags in comments | |
6 " or CDATA sections. | |
2034 | 7 " 2009-05-26 patch by Nikolai Weibull |
8 " TODO: implement pre-like tags, see xml_indent_open / xml_indent_close | |
7 | 9 |
10 " Only load this indent file when no other was loaded. | |
11 if exists("b:did_indent") | |
12 finish | |
13 endif | |
14 let b:did_indent = 1 | |
3526
dd6c2497c997
Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
15 let s:keepcpo= &cpo |
dd6c2497c997
Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
16 set cpo&vim |
7 | 17 |
18 " [-- local settings (must come before aborting the script) --] | |
19 setlocal indentexpr=XmlIndentGet(v:lnum,1) | |
20 setlocal indentkeys=o,O,*<Return>,<>>,<<>,/,{,} | |
21 | |
22 if !exists('b:xml_indent_open') | |
23 let b:xml_indent_open = '.\{-}<\a' | |
24 " pre tag, e.g. <address> | |
25 " let b:xml_indent_open = '.\{-}<[/]\@!\(address\)\@!' | |
26 endif | |
27 | |
28 if !exists('b:xml_indent_close') | |
29 let b:xml_indent_close = '.\{-}</' | |
30 " end pre tag, e.g. </address> | |
31 " let b:xml_indent_close = '.\{-}</\(address\)\@!' | |
32 endif | |
33 | |
3713 | 34 let &cpo = s:keepcpo |
35 unlet s:keepcpo | |
36 | |
7 | 37 " [-- finish, if the function already exists --] |
3713 | 38 if exists('*XmlIndentGet') |
39 finish | |
40 endif | |
41 | |
42 let s:keepcpo= &cpo | |
43 set cpo&vim | |
7 | 44 |
45 fun! <SID>XmlIndentWithPattern(line, pat) | |
46 let s = substitute('x'.a:line, a:pat, "\1", 'g') | |
47 return strlen(substitute(s, "[^\1].*$", '', '')) | |
48 endfun | |
49 | |
50 " [-- check if it's xml --] | |
51 fun! <SID>XmlIndentSynCheck(lnum) | |
52 if '' != &syntax | |
53 let syn1 = synIDattr(synID(a:lnum, 1, 1), 'name') | |
54 let syn2 = synIDattr(synID(a:lnum, strlen(getline(a:lnum)) - 1, 1), 'name') | |
55 if '' != syn1 && syn1 !~ 'xml' && '' != syn2 && syn2 !~ 'xml' | |
56 " don't indent pure non-xml code | |
57 return 0 | |
2034 | 58 elseif syn1 =~ '^xmlComment' && syn2 =~ '^xmlComment' |
59 " indent comments specially | |
60 return -1 | |
7 | 61 endif |
62 endif | |
63 return 1 | |
64 endfun | |
65 | |
66 " [-- return the sum of indents of a:lnum --] | |
67 fun! <SID>XmlIndentSum(lnum, style, add) | |
68 let line = getline(a:lnum) | |
69 if a:style == match(line, '^\s*</') | |
11518 | 70 return (shiftwidth() * |
7 | 71 \ (<SID>XmlIndentWithPattern(line, b:xml_indent_open) |
72 \ - <SID>XmlIndentWithPattern(line, b:xml_indent_close) | |
73 \ - <SID>XmlIndentWithPattern(line, '.\{-}/>'))) + a:add | |
74 else | |
75 return a:add | |
76 endif | |
77 endfun | |
78 | |
79 fun! XmlIndentGet(lnum, use_syntax_check) | |
80 " Find a non-empty line above the current line. | |
81 let lnum = prevnonblank(a:lnum - 1) | |
82 | |
83 " Hit the start of the file, use zero indent. | |
84 if lnum == 0 | |
85 return 0 | |
86 endif | |
87 | |
88 if a:use_syntax_check | |
2034 | 89 let check_lnum = <SID>XmlIndentSynCheck(lnum) |
90 let check_alnum = <SID>XmlIndentSynCheck(a:lnum) | |
91 if 0 == check_lnum || 0 == check_alnum | |
7 | 92 return indent(a:lnum) |
2034 | 93 elseif -1 == check_lnum || -1 == check_alnum |
94 return -1 | |
7 | 95 endif |
96 endif | |
97 | |
98 let ind = <SID>XmlIndentSum(lnum, -1, indent(lnum)) | |
99 let ind = <SID>XmlIndentSum(a:lnum, 0, ind) | |
100 | |
101 return ind | |
102 endfun | |
103 | |
3526
dd6c2497c997
Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
104 let &cpo = s:keepcpo |
dd6c2497c997
Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
105 unlet s:keepcpo |
dd6c2497c997
Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
106 |
7 | 107 " vim:ts=8 |