Skip to content

Commit 386ade3

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 1b14651 + 7069bf1 commit 386ade3

File tree

8 files changed

+121
-17
lines changed

8 files changed

+121
-17
lines changed

src/ex_docmd.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3878,7 +3878,6 @@ set_one_cmd_context(
38783878
case CMD_cfdo:
38793879
case CMD_confirm:
38803880
case CMD_debug:
3881-
case CMD_filter:
38823881
case CMD_folddoclosed:
38833882
case CMD_folddoopen:
38843883
case CMD_hide:
@@ -3903,6 +3902,16 @@ set_one_cmd_context(
39033902
case CMD_windo:
39043903
return arg;
39053904

3905+
case CMD_filter:
3906+
if (*arg != NUL)
3907+
arg = skip_vimgrep_pat(arg, NULL, NULL);
3908+
if (arg == NULL || *arg == NUL)
3909+
{
3910+
xp->xp_context = EXPAND_NOTHING;
3911+
return NULL;
3912+
}
3913+
return skipwhite(arg);
3914+
39063915
#ifdef FEAT_CMDL_COMPL
39073916
# ifdef FEAT_SEARCH_EXTRA
39083917
case CMD_match:

src/misc1.c

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5428,7 +5428,6 @@ static int skip_label(linenr_T, char_u **pp);
54285428
static int cin_first_id_amount(void);
54295429
static int cin_get_equal_amount(linenr_T lnum);
54305430
static int cin_ispreproc(char_u *);
5431-
static int cin_ispreproc_cont(char_u **pp, linenr_T *lnump);
54325431
static int cin_iscomment(char_u *);
54335432
static int cin_islinecomment(char_u *);
54345433
static int cin_isterminated(char_u *, int, int);
@@ -6008,13 +6007,18 @@ cin_ispreproc(char_u *s)
60086007
* Return TRUE if line "*pp" at "*lnump" is a preprocessor statement or a
60096008
* continuation line of a preprocessor statement. Decrease "*lnump" to the
60106009
* start and return the line in "*pp".
6010+
* Put the amount of indent in "*amount".
60116011
*/
60126012
static int
6013-
cin_ispreproc_cont(char_u **pp, linenr_T *lnump)
6013+
cin_ispreproc_cont(char_u **pp, linenr_T *lnump, int *amount)
60146014
{
60156015
char_u *line = *pp;
60166016
linenr_T lnum = *lnump;
60176017
int retval = FALSE;
6018+
int candidate_amount = *amount;
6019+
6020+
if (*line != NUL && line[STRLEN(line) - 1] == '\\')
6021+
candidate_amount = get_indent_lnum(lnum);
60186022

60196023
for (;;)
60206024
{
@@ -6033,6 +6037,8 @@ cin_ispreproc_cont(char_u **pp, linenr_T *lnump)
60336037

60346038
if (lnum != *lnump)
60356039
*pp = ml_get(*lnump);
6040+
if (retval)
6041+
*amount = candidate_amount;
60366042
return retval;
60376043
}
60386044

@@ -7396,7 +7402,7 @@ get_c_indent(void)
73967402
l = skipwhite(ml_get(lnum));
73977403
if (cin_nocode(l)) /* skip comment lines */
73987404
continue;
7399-
if (cin_ispreproc_cont(&l, &lnum))
7405+
if (cin_ispreproc_cont(&l, &lnum, &amount))
74007406
continue; /* ignore #define, #if, etc. */
74017407
curwin->w_cursor.lnum = lnum;
74027408

@@ -7809,10 +7815,10 @@ get_c_indent(void)
78097815
*/
78107816
if (curwin->w_cursor.lnum <= ourscope)
78117817
{
7812-
/* we reached end of scope:
7813-
* if looking for a enum or structure initialization
7818+
/* We reached end of scope:
7819+
* If looking for a enum or structure initialization
78147820
* go further back:
7815-
* if it is an initializer (enum xxx or xxx =), then
7821+
* If it is an initializer (enum xxx or xxx =), then
78167822
* don't add ind_continuation, otherwise it is a variable
78177823
* declaration:
78187824
* int x,
@@ -7851,7 +7857,8 @@ get_c_indent(void)
78517857
/*
78527858
* Skip preprocessor directives and blank lines.
78537859
*/
7854-
if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum))
7860+
if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum,
7861+
&amount))
78557862
continue;
78567863

78577864
if (cin_nocode(l))
@@ -7968,7 +7975,8 @@ get_c_indent(void)
79687975
}
79697976

79707977
/* Skip preprocessor directives and blank lines. */
7971-
if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum))
7978+
if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum,
7979+
&amount))
79727980
continue;
79737981

79747982
/* Finally the actual check for "namespace". */
@@ -8144,7 +8152,7 @@ get_c_indent(void)
81448152
* unlocked it)
81458153
*/
81468154
l = ml_get_curline();
8147-
if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum)
8155+
if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount)
81488156
|| cin_nocode(l))
81498157
continue;
81508158

@@ -8865,7 +8873,7 @@ get_c_indent(void)
88658873
/*
88668874
* Skip preprocessor directives and blank lines.
88678875
*/
8868-
if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum))
8876+
if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount))
88698877
continue;
88708878

88718879
if (cin_nocode(l))
@@ -8966,7 +8974,7 @@ get_c_indent(void)
89668974
{
89678975
look = ml_get(--curwin->w_cursor.lnum);
89688976
if (!(cin_nocode(look) || cin_ispreproc_cont(
8969-
&look, &curwin->w_cursor.lnum)))
8977+
&look, &curwin->w_cursor.lnum, &amount)))
89708978
break;
89718979
}
89728980
if (curwin->w_cursor.lnum > 0

src/testdir/test3.in

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2317,6 +2317,25 @@ h,
23172317
i;
23182318
JSEND
23192319

2320+
STARTTEST
2321+
:set cin cino&
2322+
/start of define
2323+
=/end of define
2324+
ENDTEST
2325+
2326+
/* start of define */
2327+
{
2328+
}
2329+
#define AAA \
2330+
BBB\
2331+
CCC
2332+
2333+
#define CNT \
2334+
1 + \
2335+
2 + \
2336+
4
2337+
/* end of define */
2338+
23202339
STARTTEST
23212340
:g/^STARTTEST/.,/^ENDTEST/d
23222341
:1;/start of AUTO/,$wq! test.out

src/testdir/test3.ok

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,3 +2080,17 @@ var a,
20802080
i;
20812081
JSEND
20822082

2083+
2084+
/* start of define */
2085+
{
2086+
}
2087+
#define AAA \
2088+
BBB\
2089+
CCC
2090+
2091+
#define CNT \
2092+
1 + \
2093+
2 + \
2094+
4
2095+
/* end of define */
2096+

src/testdir/test_filter_cmd.vim

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,25 @@ func Test_filter_fails()
5252
call assert_fails('filter! /pat/', 'E476:')
5353
call assert_fails('filter! /pat/ asdf', 'E492:')
5454
endfunc
55+
56+
function s:complete_filter_cmd(filtcmd)
57+
let keystroke = "\<TAB>\<C-R>=execute('let cmdline = getcmdline()')\<CR>\<C-C>"
58+
let cmdline = ''
59+
call feedkeys(':' . a:filtcmd . keystroke, 'ntx')
60+
return cmdline
61+
endfunction
62+
63+
func Test_filter_cmd_completion()
64+
" Do not complete pattern
65+
call assert_equal("filter \t", s:complete_filter_cmd('filter '))
66+
call assert_equal("filter pat\t", s:complete_filter_cmd('filter pat'))
67+
call assert_equal("filter /pat\t", s:complete_filter_cmd('filter /pat'))
68+
call assert_equal("filter /pat/\t", s:complete_filter_cmd('filter /pat/'))
69+
70+
" Complete after string pattern
71+
call assert_equal('filter pat print', s:complete_filter_cmd('filter pat pri'))
72+
73+
" Complete after regexp pattern
74+
call assert_equal('filter /pat/ print', s:complete_filter_cmd('filter /pat/ pri'))
75+
call assert_equal('filter #pat# print', s:complete_filter_cmd('filter #pat# pri'))
76+
endfunc

src/testdir/test_undo.vim

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,31 @@ func Test_insert_expr()
235235

236236
close!
237237
endfunc
238+
239+
func Test_undofile_earlier()
240+
" Issue #1254
241+
" create undofile with timestamps older than Vim startup time.
242+
let t0 = localtime() - 43200
243+
call test_settime(t0)
244+
new Xfile
245+
call feedkeys("ione\<Esc>", 'xt')
246+
set ul=100
247+
call test_settime(t0 + 1)
248+
call feedkeys("otwo\<Esc>", 'xt')
249+
set ul=100
250+
call test_settime(t0 + 2)
251+
call feedkeys("othree\<Esc>", 'xt')
252+
set ul=100
253+
w
254+
wundo Xundofile
255+
bwipe!
256+
" restore normal timestamps.
257+
call test_settime(0)
258+
new Xfile
259+
rundo Xundofile
260+
earlier 1d
261+
call assert_equal('', getline(1))
262+
bwipe!
263+
call delete('Xfile')
264+
call delete('Xundofile')
265+
endfunc

src/undo.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,10 +2298,8 @@ undo_time(
22982298
}
22992299
else
23002300
{
2301-
/* When doing computations with time_t subtract starttime, because
2302-
* time_t converted to a long may result in a wrong number. */
23032301
if (dosec)
2304-
target = (long)(curbuf->b_u_time_cur - starttime) + step;
2302+
target = (long)(curbuf->b_u_time_cur) + step;
23052303
else if (dofile)
23062304
{
23072305
if (step < 0)
@@ -2350,7 +2348,7 @@ undo_time(
23502348
else
23512349
{
23522350
if (dosec)
2353-
closest = (long)(vim_time() - starttime + 1);
2351+
closest = (long)(vim_time() + 1);
23542352
else if (dofile)
23552353
closest = curbuf->b_u_save_nr_last + 2;
23562354
else
@@ -2388,7 +2386,7 @@ undo_time(
23882386
{
23892387
uhp->uh_walk = mark;
23902388
if (dosec)
2391-
val = (long)(uhp->uh_time - starttime);
2389+
val = (long)(uhp->uh_time);
23922390
else if (dofile)
23932391
val = uhp->uh_save_nr;
23942392
else

src/version.c

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

780780
static int included_patches[] =
781781
{ /* Add new patch number below this line */
782+
/**/
783+
150,
784+
/**/
785+
149,
786+
/**/
787+
148,
782788
/**/
783789
147,
784790
/**/

0 commit comments

Comments
 (0)