1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0574
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 8.1.0574
Problem: 'commentstring' not used when adding fold marker in C.
Solution: Require white space before middle comment part. (mostly by
Hirohito Higashi)
Files: src/misc1.c, src/testdir/test_fold.vim
*** ../vim-8.1.0573/src/misc1.c 2018-12-07 21:08:44.775946983 +0100
--- src/misc1.c 2018-12-09 14:50:25.241083939 +0100
***************
*** 1993,1999 ****
for (list = curbuf->b_p_com; *list; )
{
char_u *flags_save = list;
- int is_only_whitespace = FALSE;
/*
* Get one option part into part_buf[]. Advance list to next one.
--- 1993,1998 ----
***************
*** 2021,2028 ****
continue;
while (VIM_ISWHITE(*string))
++string;
- if (*string == NUL)
- is_only_whitespace = TRUE;
}
for (j = 0; string[j] != NUL && string[j] == line[i + j]; ++j)
/* do nothing */;
--- 2020,2025 ----
***************
*** 2037,2047 ****
&& !VIM_ISWHITE(line[i + j]) && line[i + j] != NUL)
continue;
! // For a middlepart comment that is only white space, only consider
! // it to match if everything before the current position in the
! // line is also whitespace.
! if (is_only_whitespace && vim_strchr(part_buf, COM_MIDDLE) != NULL)
{
for (j = 0; VIM_ISWHITE(line[j]) && j <= i; j++)
;
if (j < i)
--- 2034,2046 ----
&& !VIM_ISWHITE(line[i + j]) && line[i + j] != NUL)
continue;
! if (vim_strchr(part_buf, COM_MIDDLE) != NULL)
{
+ // For a middlepart comment, only consider it to match if
+ // everything before the current position in the line is
+ // whitespace. Otherwise we would think we are inside a
+ // comment if the middle part appears somewhere in the middle
+ // of the line. E.g. for C the "*" appears often.
for (j = 0; VIM_ISWHITE(line[j]) && j <= i; j++)
;
if (j < i)
*** ../vim-8.1.0573/src/testdir/test_fold.vim 2018-12-07 21:08:44.775946983 +0100
--- src/testdir/test_fold.vim 2018-12-09 15:00:39.993843356 +0100
***************
*** 507,512 ****
--- 507,541 ----
enew!
endfunc
+ " test create fold markers with C filetype
+ func Test_fold_create_marker_in_C()
+ enew!
+ set fdm=marker fdl=9
+ set filetype=c
+
+ let content = [
+ \ '/*',
+ \ ' * comment',
+ \ ' * ',
+ \ ' *',
+ \ ' */',
+ \ 'int f(int* p) {',
+ \ ' *p = 3;',
+ \ ' return 0;',
+ \ '}'
+ \]
+ for c in range(len(content) - 1)
+ bw!
+ call append(0, content)
+ call cursor(c + 1, 1)
+ norm! zfG
+ call assert_equal(content[c] . (c < 4 ? '{{{' : '/*{{{*/'), getline(c + 1))
+ endfor
+
+ set fdm& fdl&
+ enew!
+ endfunc
+
" test folding with indent
func Test_fold_indent()
enew!
*** ../vim-8.1.0573/src/version.c 2018-12-08 16:03:18.656085902 +0100
--- src/version.c 2018-12-09 14:59:36.034199905 +0100
***************
*** 794,795 ****
--- 794,797 ----
{ /* Add new patch number below this line */
+ /**/
+ 574,
/**/
--
Scientists decoded the first message from an alien civilization:
SIMPLY SEND 6 TIMES 10 TO THE 50 ATOMS OF HYDROGEN TO THE STAR
SYSTEM AT THE TOP OF THE LIST, CROSS OFF THAT STAR SYSTEM, THEN PUT
YOUR STAR SYSTEM AT THE BOTTOM OF THE LIST AND SEND IT TO 100 OTHER
STAR SYSTEMS. WITHIN ONE TENTH GALACTIC ROTATION YOU WILL RECEIVE
ENOUGH HYDROGREN TO POWER YOUR CIVILIZATION UNTIL ENTROPY REACHES ITS
MAXIMUM! IT REALLY WORKS!
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|