Mercurial > vim
annotate runtime/indent/vb.vim @ 17722:bf807c68ac80 v8.1.1858
patch 8.1.1858: test for multi-byte mapping fails on some systems
commit https://github.com/vim/vim/commit/2f710afe7f166973c879bf7424678ba84368c1bb
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Aug 16 20:56:03 2019 +0200
patch 8.1.1858: test for multi-byte mapping fails on some systems
Problem: Test for multi-byte mapping fails on some systems.
Solution: Test in another way.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 16 Aug 2019 21:00:03 +0200 |
parents | 63b0b7b79b25 |
children | 7d68a90cbf5c |
rev | line source |
---|---|
7 | 1 " Vim indent file |
2 " Language: VisualBasic (ft=vb) / Basic (ft=basic) / SaxBasic (ft=vb) | |
3 " Author: Johannes Zellner <johannes@zellner.org> | |
9 | 4 " Last Change: Fri, 18 Jun 2004 07:22:42 CEST |
2421 | 5 " Small update 2010 Jul 28 by Maxim Kim |
7 | 6 |
7 if exists("b:did_indent") | |
8 finish | |
9 endif | |
10 let b:did_indent = 1 | |
11 | |
233 | 12 setlocal autoindent |
7 | 13 setlocal indentexpr=VbGetIndent(v:lnum) |
14 setlocal indentkeys& | |
9 | 15 setlocal indentkeys+==~else,=~elseif,=~end,=~wend,=~case,=~next,=~select,=~loop,<:> |
7 | 16 |
233 | 17 let b:undo_indent = "set ai< indentexpr< indentkeys<" |
18 | |
7 | 19 " Only define the function once. |
20 if exists("*VbGetIndent") | |
21 finish | |
22 endif | |
23 | |
24 fun! VbGetIndent(lnum) | |
25 " labels and preprocessor get zero indent immediately | |
26 let this_line = getline(a:lnum) | |
27 let LABELS_OR_PREPROC = '^\s*\(\<\k\+\>:\s*$\|#.*\)' | |
28 if this_line =~? LABELS_OR_PREPROC | |
29 return 0 | |
30 endif | |
31 | |
32 " Find a non-blank line above the current line. | |
33 " Skip over labels and preprocessor directives. | |
34 let lnum = a:lnum | |
35 while lnum > 0 | |
36 let lnum = prevnonblank(lnum - 1) | |
37 let previous_line = getline(lnum) | |
38 if previous_line !~? LABELS_OR_PREPROC | |
39 break | |
40 endif | |
41 endwhile | |
42 | |
43 " Hit the start of the file, use zero indent. | |
44 if lnum == 0 | |
45 return 0 | |
46 endif | |
47 | |
48 let ind = indent(lnum) | |
49 | |
50 " Add | |
2432
80229a724a11
Updated runtime files. :TOhtml improvements by Benjamin Fritz.
Bram Moolenaar <bram@vim.org>
parents:
2421
diff
changeset
|
51 if previous_line =~? '^\s*\<\(begin\|\%(\%(private\|public\|friend\)\s\+\)\=\%(function\|sub\|property\)\|select\|case\|default\|if\|else\|elseif\|do\|for\|while\|enum\|with\)\>' |
11518 | 52 let ind = ind + shiftwidth() |
7 | 53 endif |
54 | |
55 " Subtract | |
56 if this_line =~? '^\s*\<end\>\s\+\<select\>' | |
57 if previous_line !~? '^\s*\<select\>' | |
11518 | 58 let ind = ind - 2 * shiftwidth() |
7 | 59 else |
60 " this case is for an empty 'select' -- 'end select' | |
61 " (w/o any case statements) like: | |
62 " | |
63 " select case readwrite | |
64 " end select | |
11518 | 65 let ind = ind - shiftwidth() |
7 | 66 endif |
2421 | 67 elseif this_line =~? '^\s*\<\(end\|else\|elseif\|until\|loop\|next\|wend\)\>' |
11518 | 68 let ind = ind - shiftwidth() |
7 | 69 elseif this_line =~? '^\s*\<\(case\|default\)\>' |
70 if previous_line !~? '^\s*\<select\>' | |
11518 | 71 let ind = ind - shiftwidth() |
7 | 72 endif |
73 endif | |
74 | |
75 return ind | |
76 endfun | |
2421 | 77 |
78 " vim:sw=4 |