mirror of
https://github.com/neovim/neovim.git
synced 2025-09-20 02:08:17 +00:00
vim-patch:8.1.0570: 'commentstring' not used when adding fold marker (#9331)
Problem: 'commentstring' not used when adding fold marker. (Maxim Kim)
Solution: Only use empty 'comments' middle when leader is empty. (Christian
Brabandt, closes vim/vim#3670)
539328197c
This commit is contained in:

committed by
Justin M. Keyes

parent
bd97577954
commit
f1eb25f0c4
@@ -1099,6 +1099,7 @@ int get_last_leader_offset(char_u *line, char_u **flags)
|
|||||||
found_one = FALSE;
|
found_one = FALSE;
|
||||||
for (list = curbuf->b_p_com; *list; ) {
|
for (list = curbuf->b_p_com; *list; ) {
|
||||||
char_u *flags_save = list;
|
char_u *flags_save = list;
|
||||||
|
bool is_only_whitespace = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get one option part into part_buf[]. Advance list to next one.
|
* Get one option part into part_buf[]. Advance list to next one.
|
||||||
@@ -1122,8 +1123,12 @@ int get_last_leader_offset(char_u *line, char_u **flags)
|
|||||||
if (ascii_iswhite(string[0])) {
|
if (ascii_iswhite(string[0])) {
|
||||||
if (i == 0 || !ascii_iswhite(line[i - 1]))
|
if (i == 0 || !ascii_iswhite(line[i - 1]))
|
||||||
continue;
|
continue;
|
||||||
while (ascii_iswhite(string[0]))
|
while (ascii_iswhite(*string)) {
|
||||||
++string;
|
string++;
|
||||||
|
}
|
||||||
|
if (*string == NUL) {
|
||||||
|
is_only_whitespace = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (j = 0; string[j] != NUL && string[j] == line[i + j]; ++j)
|
for (j = 0; string[j] != NUL && string[j] == line[i + j]; ++j)
|
||||||
/* do nothing */;
|
/* do nothing */;
|
||||||
@@ -1139,6 +1144,17 @@ int get_last_leader_offset(char_u *line, char_u **flags)
|
|||||||
continue;
|
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; ascii_iswhite(line[j]) && j <= i; j++) {
|
||||||
|
}
|
||||||
|
if (j < i) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We have found a match, stop searching.
|
* We have found a match, stop searching.
|
||||||
*/
|
*/
|
||||||
|
@@ -674,3 +674,20 @@ func Test_fold_last_line_with_pagedown()
|
|||||||
set fdm&
|
set fdm&
|
||||||
enew!
|
enew!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_folds_marker_in_comment2()
|
||||||
|
new
|
||||||
|
call setline(1, ['Lorem ipsum dolor sit', 'Lorem ipsum dolor sit', 'Lorem ipsum dolor sit'])
|
||||||
|
setl fen fdm=marker
|
||||||
|
setl commentstring=<!--%s-->
|
||||||
|
setl comments=s:<!--,m:\ \ \ \ ,e:-->
|
||||||
|
norm! zf2j
|
||||||
|
setl nofen
|
||||||
|
:1y
|
||||||
|
call assert_equal(['Lorem ipsum dolor sit<!--{{{-->'], getreg(0,1,1))
|
||||||
|
:+2y
|
||||||
|
call assert_equal(['Lorem ipsum dolor sit<!--}}}-->'], getreg(0,1,1))
|
||||||
|
|
||||||
|
set foldmethod&
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
Reference in New Issue
Block a user