Mercurial > vim
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 |
rev | line source |
---|---|
7 | 1 " Vim indent file |
389 | 2 " Language: CSS |
839 | 3 " Maintainer: Nikolai Weibull <now@bitwi.se> |
3557 | 4 " Latest Revision: 2012-05-30 |
11062 | 5 " Use of shiftwidth() added by Oleg Zubchenko. |
7 | 6 |
7 if exists("b:did_indent") | |
8 finish | |
9 endif | |
10 let b:did_indent = 1 | |
11 | |
12 setlocal indentexpr=GetCSSIndent() | |
375 | 13 setlocal indentkeys=0{,0},!^F,o,O |
1189 | 14 setlocal nosmartindent |
7 | 15 |
3557 | 16 let b:undo_indent = "setl smartindent< indentkeys< indentexpr<" |
17 | |
7 | 18 if exists("*GetCSSIndent") |
19 finish | |
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 | 23 |
389 | 24 function s:prevnonblanknoncomment(lnum) |
25 let lnum = a:lnum | |
26 while lnum > 1 | |
27 let lnum = prevnonblank(lnum) | |
375 | 28 let line = getline(lnum) |
29 if line =~ '\*/' | |
389 | 30 while lnum > 1 && line !~ '/\*' |
1189 | 31 let lnum -= 1 |
375 | 32 endwhile |
389 | 33 if line =~ '^\s*/\*' |
1189 | 34 let lnum -= 1 |
389 | 35 else |
1189 | 36 break |
389 | 37 endif |
38 else | |
39 break | |
375 | 40 endif |
41 endwhile | |
42 return lnum | |
43 endfunction | |
44 | |
389 | 45 function s:count_braces(lnum, count_open) |
46 let n_open = 0 | |
47 let n_close = 0 | |
48 let line = getline(a:lnum) | |
49 let pattern = '[{}]' | |
50 let i = match(line, pattern) | |
51 while i != -1 | |
52 if synIDattr(synID(a:lnum, i + 1, 0), 'name') !~ 'css\%(Comment\|StringQ\{1,2}\)' | |
53 if line[i] == '{' | |
1189 | 54 let n_open += 1 |
389 | 55 elseif line[i] == '}' |
1189 | 56 if n_open > 0 |
57 let n_open -= 1 | |
58 else | |
59 let n_close += 1 | |
60 endif | |
389 | 61 endif |
62 endif | |
63 let i = match(line, pattern, i + 1) | |
64 endwhile | |
65 return a:count_open ? n_open : n_close | |
66 endfunction | |
67 | |
375 | 68 function GetCSSIndent() |
389 | 69 let line = getline(v:lnum) |
70 if line =~ '^\s*\*' | |
71 return cindent(v:lnum) | |
72 endif | |
73 | |
74 let pnum = s:prevnonblanknoncomment(v:lnum - 1) | |
75 if pnum == 0 | |
7 | 76 return 0 |
77 endif | |
78 | |
11062 | 79 return indent(pnum) + s:count_braces(pnum, 1) * shiftwidth() |
80 \ - s:count_braces(v:lnum, 0) * shiftwidth() | |
7 | 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 |