annotate runtime/indent/css.vim @ 20534:ae758aa4ee5e v8.2.0821

patch 8.2.0821: Vim9: memory leak in expr test Commit: https://github.com/vim/vim/commit/45a1508a229b1d1d2eb79cabe55a183dc18fd040 Author: Bram Moolenaar <Bram@vim.org> Date: Mon May 25 00:28:33 2020 +0200 patch 8.2.0821: Vim9: memory leak in expr test Problem: Vim9: memory leak in expr test. Solution: Do not decrement the length of the list of functions if the current function is not at the end.
author Bram Moolenaar <Bram@vim.org>
date Mon, 25 May 2020 00:30:03 +0200
parents 1218c5353e2b
children 9c221ad9634a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim indent file
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
2 " Language: CSS
839
1f3b1021f002 updated for version 7.0e05
vimboss
parents: 389
diff changeset
3 " Maintainer: Nikolai Weibull <now@bitwi.se>
3557
9cb3a75a20b9 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
4 " Latest Revision: 2012-05-30
11062
1218c5353e2b Runtime file updates.
Christian Brabandt <cb@256bit.org>
parents: 3557
diff changeset
5 " Use of shiftwidth() added by Oleg Zubchenko.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 setlocal indentexpr=GetCSSIndent()
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
13 setlocal indentkeys=0{,0},!^F,o,O
1189
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
14 setlocal nosmartindent
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3557
9cb3a75a20b9 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
16 let b:undo_indent = "setl smartindent< indentkeys< indentexpr<"
9cb3a75a20b9 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
17
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 if exists("*GetCSSIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 endif
3526
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2698
diff changeset
21 let s:keepcpo= &cpo
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2698
diff changeset
22 set cpo&vim
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
24 function s:prevnonblanknoncomment(lnum)
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
25 let lnum = a:lnum
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
26 while lnum > 1
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
27 let lnum = prevnonblank(lnum)
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
28 let line = getline(lnum)
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
29 if line =~ '\*/'
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
30 while lnum > 1 && line !~ '/\*'
1189
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
31 let lnum -= 1
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
32 endwhile
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
33 if line =~ '^\s*/\*'
1189
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
34 let lnum -= 1
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
35 else
1189
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
36 break
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
37 endif
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
38 else
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
39 break
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
40 endif
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
41 endwhile
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
42 return lnum
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
43 endfunction
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
44
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
45 function s:count_braces(lnum, count_open)
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
46 let n_open = 0
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
47 let n_close = 0
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
48 let line = getline(a:lnum)
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
49 let pattern = '[{}]'
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
50 let i = match(line, pattern)
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
51 while i != -1
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
52 if synIDattr(synID(a:lnum, i + 1, 0), 'name') !~ 'css\%(Comment\|StringQ\{1,2}\)'
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
53 if line[i] == '{'
1189
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
54 let n_open += 1
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
55 elseif line[i] == '}'
1189
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
56 if n_open > 0
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
57 let n_open -= 1
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
58 else
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
59 let n_close += 1
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
60 endif
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
61 endif
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
62 endif
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
63 let i = match(line, pattern, i + 1)
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
64 endwhile
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
65 return a:count_open ? n_open : n_close
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
66 endfunction
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
67
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
68 function GetCSSIndent()
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
69 let line = getline(v:lnum)
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
70 if line =~ '^\s*\*'
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
71 return cindent(v:lnum)
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
72 endif
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
73
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
74 let pnum = s:prevnonblanknoncomment(v:lnum - 1)
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
75 if pnum == 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78
11062
1218c5353e2b Runtime file updates.
Christian Brabandt <cb@256bit.org>
parents: 3557
diff changeset
79 return indent(pnum) + s:count_braces(pnum, 1) * shiftwidth()
1218c5353e2b Runtime file updates.
Christian Brabandt <cb@256bit.org>
parents: 3557
diff changeset
80 \ - s:count_braces(v:lnum, 0) * shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 endfunction
3526
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2698
diff changeset
82
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2698
diff changeset
83 let &cpo = s:keepcpo
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2698
diff changeset
84 unlet s:keepcpo