Skip to content

Commit 4638209

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents bfe75bf + 5b276aa commit 4638209

File tree

9 files changed

+139
-57
lines changed

9 files changed

+139
-57
lines changed

runtime/doc/eval.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6945,6 +6945,7 @@ setqflist({list} [, {action}[, {what}]]) *setqflist()*
69456945
nr error number
69466946
text description of the error
69476947
type single-character error type, 'E', 'W', etc.
6948+
valid recognized error message
69486949

69496950
The "col", "vcol", "nr", "type" and "text" entries are
69506951
optional. Either "lnum" or "pattern" entry can be used to
@@ -6954,6 +6955,8 @@ setqflist({list} [, {action}[, {what}]]) *setqflist()*
69546955
item will not be handled as an error line.
69556956
If both "pattern" and "lnum" are present then "pattern" will
69566957
be used.
6958+
If the "valid" entry is not supplied, then the valid flag is
6959+
set when "bufnr" is a valid buffer or "filename" exists.
69576960
If you supply an empty {list}, the quickfix list will be
69586961
cleared.
69596962
Note that the list is not exactly the same as what

src/fold.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3133,10 +3133,14 @@ foldMoveRange(garray_T *gap, linenr_T line1, linenr_T line2, linenr_T dest)
31333133
dest_index = fold_index(fp, gap);
31343134

31353135
/*
3136-
* All folds are now correct, but they are not necessarily in the correct
3137-
* order. We have to swap folds in the range [move_end, dest_index) with
3138-
* those in the range [move_start, move_end).
3136+
* All folds are now correct, but not necessarily in the correct order. We
3137+
* must swap folds in the range [move_end, dest_index) with those in the
3138+
* range [move_start, move_end).
31393139
*/
3140+
if (move_end == 0)
3141+
/* There are no folds after those moved, hence no folds have been moved
3142+
* out of order. */
3143+
return;
31403144
foldReverseOrder(gap, (linenr_T)move_start, (linenr_T)dest_index - 1);
31413145
foldReverseOrder(gap, (linenr_T)move_start,
31423146
(linenr_T)(move_start + dest_index - move_end - 1));

src/gui_w32.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2627,7 +2627,9 @@ gui_mch_set_curtab(int nr)
26272627
void
26282628
ex_simalt(exarg_T *eap)
26292629
{
2630-
char_u *keys = eap->arg;
2630+
char_u *keys = eap->arg;
2631+
int fill_typebuf = FALSE;
2632+
char_u key_name[4];
26312633

26322634
PostMessage(s_hwnd, WM_SYSCOMMAND, (WPARAM)SC_KEYMENU, (LPARAM)0);
26332635
while (*keys)
@@ -2636,6 +2638,18 @@ ex_simalt(exarg_T *eap)
26362638
*keys = ' '; /* for showing system menu */
26372639
PostMessage(s_hwnd, WM_CHAR, (WPARAM)*keys, (LPARAM)0);
26382640
keys++;
2641+
fill_typebuf = TRUE;
2642+
}
2643+
if (fill_typebuf)
2644+
{
2645+
/* Put something in the typeahead buffer so that the message will get
2646+
* processed. */
2647+
key_name[0] = K_SPECIAL;
2648+
key_name[1] = KS_EXTRA;
2649+
key_name[2] = KE_IGNORE;
2650+
key_name[3] = NUL;
2651+
typebuf_was_filled = TRUE;
2652+
(void)ins_typebuf(key_name, REMAP_NONE, 0, TRUE, FALSE);
26392653
}
26402654
}
26412655

src/quickfix.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4779,6 +4779,10 @@ qf_add_entries(
47794779
bufnum = 0;
47804780
}
47814781

4782+
/* If the 'valid' field is present it overrules the detected value. */
4783+
if ((dict_find(d, (char_u *)"valid", -1)) != NULL)
4784+
valid = (int)get_dict_number(d, (char_u *)"valid");
4785+
47824786
status = qf_add_entry(qi,
47834787
NULL, /* dir */
47844788
filename,

src/spell.c

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3123,7 +3123,7 @@ spell_iswordp(
31233123

31243124
if (has_mbyte)
31253125
{
3126-
l = MB_BYTE2LEN(*p);
3126+
l = MB_PTR2LEN(p);
31273127
s = p;
31283128
if (l == 1)
31293129
{
@@ -3808,6 +3808,10 @@ spell_find_suggest(
38083808
vim_strncpy(su->su_badword, su->su_badptr, su->su_badlen);
38093809
(void)spell_casefold(su->su_badptr, su->su_badlen,
38103810
su->su_fbadword, MAXWLEN);
3811+
/* TODO: make this work if the case-folded text is longer than the original
3812+
* text. Currently an illegal byte causes wrong pointer computations. */
3813+
su->su_fbadword[su->su_badlen] = NUL;
3814+
38113815
/* get caps flags for bad word */
38123816
su->su_badflags = badword_captype(su->su_badptr,
38133817
su->su_badptr + su->su_badlen);
@@ -4937,12 +4941,7 @@ suggest_trie_walk(
49374941
{
49384942
int l;
49394943

4940-
#ifdef FEAT_MBYTE
4941-
if (has_mbyte)
4942-
l = MB_BYTE2LEN(fword[sp->ts_fidx]);
4943-
else
4944-
#endif
4945-
l = 1;
4944+
l = MB_PTR2LEN(fword + sp->ts_fidx);
49464945
if (fword_ends)
49474946
{
49484947
/* Copy the skipped character to preword. */
@@ -5109,9 +5108,8 @@ suggest_trie_walk(
51095108
/* Correct ts_fidx for the byte length of the
51105109
* character (we didn't check that before). */
51115110
sp->ts_fidx = sp->ts_fcharstart
5112-
+ MB_BYTE2LEN(
5113-
fword[sp->ts_fcharstart]);
5114-
5111+
+ MB_PTR2LEN(
5112+
fword + sp->ts_fcharstart);
51155113
/* For changing a composing character adjust
51165114
* the score from SCORE_SUBST to
51175115
* SCORE_SUBCOMP. */
@@ -5232,7 +5230,7 @@ suggest_trie_walk(
52325230
if (has_mbyte)
52335231
{
52345232
c = mb_ptr2char(fword + sp->ts_fidx);
5235-
stack[depth].ts_fidx += MB_BYTE2LEN(fword[sp->ts_fidx]);
5233+
stack[depth].ts_fidx += MB_PTR2LEN(fword + sp->ts_fidx);
52365234
if (enc_utf8 && utf_iscomposing(c))
52375235
stack[depth].ts_score -= SCORE_DEL - SCORE_DELCOMP;
52385236
else if (c == mb_ptr2char(fword + stack[depth].ts_fidx))
@@ -5456,9 +5454,9 @@ suggest_trie_walk(
54565454
#ifdef FEAT_MBYTE
54575455
if (has_mbyte)
54585456
{
5459-
n = MB_BYTE2LEN(*p);
5457+
n = MB_PTR2LEN(p);
54605458
c = mb_ptr2char(p + n);
5461-
mch_memmove(p + MB_BYTE2LEN(p[n]), p, n);
5459+
mch_memmove(p + MB_PTR2LEN(p + n), p, n);
54625460
mb_char2bytes(c, p);
54635461
}
54645462
else
@@ -5550,11 +5548,11 @@ suggest_trie_walk(
55505548
#ifdef FEAT_MBYTE
55515549
if (has_mbyte)
55525550
{
5553-
n = MB_BYTE2LEN(*p);
5551+
n = MB_PTR2LEN(p);
55545552
c2 = mb_ptr2char(p + n);
5555-
fl = MB_BYTE2LEN(p[n]);
5553+
fl = MB_PTR2LEN(p + n);
55565554
c = mb_ptr2char(p + n + fl);
5557-
tl = MB_BYTE2LEN(p[n + fl]);
5555+
tl = MB_PTR2LEN(p + n + fl);
55585556
mch_memmove(p + fl + tl, p, n);
55595557
mb_char2bytes(c, p);
55605558
mb_char2bytes(c2, p + tl);
@@ -5627,10 +5625,10 @@ suggest_trie_walk(
56275625
#ifdef FEAT_MBYTE
56285626
if (has_mbyte)
56295627
{
5630-
n = MB_BYTE2LEN(*p);
5631-
n += MB_BYTE2LEN(p[n]);
5628+
n = MB_PTR2LEN(p);
5629+
n += MB_PTR2LEN(p + n);
56325630
c = mb_ptr2char(p + n);
5633-
tl = MB_BYTE2LEN(p[n]);
5631+
tl = MB_PTR2LEN(p + n);
56345632
mch_memmove(p + tl, p, n);
56355633
mb_char2bytes(c, p);
56365634
}
@@ -5693,9 +5691,9 @@ suggest_trie_walk(
56935691
if (has_mbyte)
56945692
{
56955693
c = mb_ptr2char(p);
5696-
tl = MB_BYTE2LEN(*p);
5697-
n = MB_BYTE2LEN(p[tl]);
5698-
n += MB_BYTE2LEN(p[tl + n]);
5694+
tl = MB_PTR2LEN(p);
5695+
n = MB_PTR2LEN(p + tl);
5696+
n += MB_PTR2LEN(p + tl + n);
56995697
mch_memmove(p, p + tl, n);
57005698
mb_char2bytes(c, p + n);
57015699
}

src/testdir/test_fold.vim

Lines changed: 52 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
" Test for folding
22

3-
func! PrepIndent(arg)
3+
func PrepIndent(arg)
44
return [a:arg] + repeat(["\t".a:arg], 5)
55
endfu
66

7-
func! Test_address_fold()
7+
func Test_address_fold()
88
new
99
call setline(1, ['int FuncName() {/*{{{*/', 1, 2, 3, 4, 5, '}/*}}}*/',
1010
\ 'after fold 1', 'after fold 2', 'after fold 3'])
@@ -68,17 +68,7 @@ func! Test_address_fold()
6868
quit!
6969
endfunc
7070

71-
func! Test_indent_fold()
72-
new
73-
call setline(1, ['', 'a', ' b', ' c'])
74-
setl fen fdm=indent
75-
2
76-
norm! >>
77-
let a=map(range(1,4), 'foldclosed(v:val)')
78-
call assert_equal([-1,-1,-1,-1], a)
79-
endfunc
80-
81-
func! Test_indent_fold()
71+
func Test_indent_fold()
8272
new
8373
call setline(1, ['', 'a', ' b', ' c'])
8474
setl fen fdm=indent
@@ -89,7 +79,7 @@ func! Test_indent_fold()
8979
bw!
9080
endfunc
9181

92-
func! Test_indent_fold2()
82+
func Test_indent_fold2()
9383
new
9484
call setline(1, ['', '{{{', '}}}', '{{{', '}}}'])
9585
setl fen fdm=marker
@@ -122,7 +112,7 @@ func Test_manual_fold_with_filter()
122112
endfor
123113
endfunc
124114

125-
func! Test_indent_fold_with_read()
115+
func Test_indent_fold_with_read()
126116
new
127117
set foldmethod=indent
128118
call setline(1, repeat(["\<Tab>a"], 4))
@@ -224,7 +214,11 @@ func Test_update_folds_expr_read()
224214
set foldmethod& foldexpr&
225215
endfunc
226216

227-
func! Test_move_folds_around_manual()
217+
func Check_foldlevels(expected)
218+
call assert_equal(a:expected, map(range(1, line('$')), 'foldlevel(v:val)'))
219+
endfunc
220+
221+
func Test_move_folds_around_manual()
228222
new
229223
let input = PrepIndent("a") + PrepIndent("b") + PrepIndent("c")
230224
call setline(1, PrepIndent("a") + PrepIndent("b") + PrepIndent("c"))
@@ -293,11 +287,50 @@ func! Test_move_folds_around_manual()
293287
6m$
294288
" The first fold has been truncated to the 5'th line.
295289
" Second fold has been moved up because the moved line is now below it.
296-
call assert_equal([0, 1, 1, 1, 1, 0, 0, 0, 1, 0], map(range(1, line('$')), 'foldlevel(v:val)'))
290+
call Check_foldlevels([0, 1, 1, 1, 1, 0, 0, 0, 1, 0])
291+
292+
%delete
293+
set fdm=indent foldlevel=0
294+
call setline(1, [
295+
\ "a",
296+
\ "\ta",
297+
\ "\t\ta",
298+
\ "\t\ta",
299+
\ "\t\ta",
300+
\ "a",
301+
\ "a"])
302+
set fdm=manual
303+
%foldopen!
304+
4,5m6
305+
call Check_foldlevels([0, 1, 2, 0, 0, 0, 0])
306+
307+
%delete
308+
set fdm=indent
309+
call setline(1, [
310+
\ "\ta",
311+
\ "\t\ta",
312+
\ "\t\ta",
313+
\ "\t\ta",
314+
\ "\ta",
315+
\ "\t\ta",
316+
\ "\t\ta",
317+
\ "\t\ta",
318+
\ "\ta",
319+
\ "\t\ta",
320+
\ "\t\ta",
321+
\ "\t\ta",
322+
\ "\t\ta",
323+
\ "\ta",
324+
\ "a"])
325+
set fdm=manual
326+
%foldopen!
327+
13m7
328+
call Check_foldlevels([1, 2, 2, 2, 1, 2, 2, 1, 1, 1, 2, 2, 2, 1, 0])
329+
297330
bw!
298331
endfunc
299332

300-
func! Test_move_folds_around_indent()
333+
func Test_move_folds_around_indent()
301334
new
302335
let input = PrepIndent("a") + PrepIndent("b") + PrepIndent("c")
303336
call setline(1, PrepIndent("a") + PrepIndent("b") + PrepIndent("c"))
@@ -357,7 +390,7 @@ func! Test_move_folds_around_indent()
357390
6m$
358391
" The first fold has been truncated to the 5'th line.
359392
" Second fold has been moved up because the moved line is now below it.
360-
call assert_equal([0, 1, 1, 1, 1, 0, 0, 0, 1, 1], map(range(1, line('$')), 'foldlevel(v:val)'))
393+
call Check_foldlevels([0, 1, 1, 1, 1, 0, 0, 0, 1, 1])
361394
bw!
362395
endfunc
363396

src/testdir/test_quickfix.vim

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,6 +1201,25 @@ func SetXlistTests(cchar, bnum)
12011201
let l = g:Xgetlist()
12021202
call assert_equal(0, len(l))
12031203

1204+
" Tests for setting the 'valid' flag
1205+
call g:Xsetlist([{'bufnr':a:bnum, 'lnum':4, 'valid':0}])
1206+
Xwindow
1207+
call assert_equal(1, winnr('$'))
1208+
let l = g:Xgetlist()
1209+
call g:Xsetlist(l)
1210+
call assert_equal(0, g:Xgetlist()[0].valid)
1211+
call g:Xsetlist([{'text':'Text1', 'valid':1}])
1212+
Xwindow
1213+
call assert_equal(2, winnr('$'))
1214+
Xclose
1215+
let save_efm = &efm
1216+
set efm=%m
1217+
Xgetexpr 'TestMessage'
1218+
let l = g:Xgetlist()
1219+
call g:Xsetlist(l)
1220+
call assert_equal(1, g:Xgetlist()[0].valid)
1221+
let &efm = save_efm
1222+
12041223
" Error cases:
12051224
" Refer to a non-existing buffer and pass a non-dictionary type
12061225
call assert_fails("call g:Xsetlist([{'bufnr':998, 'lnum':4}," .
@@ -2022,15 +2041,3 @@ func Test_qf_free()
20222041
call XfreeTests('c')
20232042
call XfreeTests('l')
20242043
endfunc
2025-
2026-
func Test_no_reuse_mem()
2027-
set efm=E,%W%m,
2028-
cgetexpr ['C']
2029-
set efm=%C%m
2030-
lexpr '0'
2031-
lopen
2032-
call setqflist([], 'r')
2033-
caddbuf
2034-
2035-
set efm&
2036-
endfunc

src/testdir/test_spell.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,12 @@ func Test_wrap_search()
1818
bwipe!
1919
set nospell
2020
endfunc
21+
22+
func Test_z_equal_on_invalid_utf8_word()
23+
split
24+
set spell
25+
call setline(1, "\xff")
26+
norm z=
27+
set nospell
28+
bwipe!
29+
endfunc

src/version.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,16 @@ static char *(features[]) =
779779

780780
static int included_patches[] =
781781
{ /* Add new patch number below this line */
782+
/**/
783+
582,
784+
/**/
785+
581,
786+
/**/
787+
580,
788+
/**/
789+
579,
790+
/**/
791+
578,
782792
/**/
783793
577,
784794
/**/

0 commit comments

Comments
 (0)