Skip to content

Commit 40bc4e9

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 0bdef25 + 9b73c4a commit 40bc4e9

File tree

9 files changed

+43
-12
lines changed

9 files changed

+43
-12
lines changed

src/buffer.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,19 @@ read_buffer(
113113
* it can be changed there. */
114114
if (!readonlymode && !bufempty())
115115
changed();
116-
else if (retval != FAIL)
116+
else if (retval == OK)
117117
unchanged(curbuf, FALSE);
118118

119119
#ifdef FEAT_AUTOCMD
120+
if (retval == OK)
121+
{
120122
# ifdef FEAT_EVAL
121-
apply_autocmds_retval(EVENT_STDINREADPOST, NULL, NULL, FALSE,
123+
apply_autocmds_retval(EVENT_STDINREADPOST, NULL, NULL, FALSE,
122124
curbuf, &retval);
123125
# else
124-
apply_autocmds(EVENT_STDINREADPOST, NULL, NULL, FALSE, curbuf);
126+
apply_autocmds(EVENT_STDINREADPOST, NULL, NULL, FALSE, curbuf);
125127
# endif
128+
}
126129
#endif
127130
}
128131
return retval;
@@ -294,7 +297,7 @@ open_buffer(
294297
#endif
295298
)
296299
changed();
297-
else if (retval != FAIL && !read_stdin && !read_fifo)
300+
else if (retval == OK && !read_stdin && !read_fifo)
298301
unchanged(curbuf, FALSE);
299302
save_file_ff(curbuf); /* keep this fileformat */
300303

@@ -328,7 +331,7 @@ open_buffer(
328331
# endif
329332
#endif
330333

331-
if (retval != FAIL)
334+
if (retval == OK)
332335
{
333336
#ifdef FEAT_AUTOCMD
334337
/*

src/ex_cmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,7 @@ do_filter(
13131313
if (otmp != NULL)
13141314
{
13151315
if (readfile(otmp, NULL, line2, (linenr_T)0, (linenr_T)MAXLNUM,
1316-
eap, READ_FILTER) == FAIL)
1316+
eap, READ_FILTER) != OK)
13171317
{
13181318
#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
13191319
if (!aborting())

src/ex_docmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8876,7 +8876,7 @@ ex_read(exarg_T *eap)
88768876
eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0);
88778877

88788878
}
8879-
if (i == FAIL)
8879+
if (i != OK)
88808880
{
88818881
#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
88828882
if (!aborting())

src/fileio.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ filemess(
210210
* READ_KEEP_UNDO don't clear undo info or read it from a file
211211
* READ_FIFO read from fifo/socket instead of a file
212212
*
213-
* return FAIL for failure, OK otherwise
213+
* return FAIL for failure, NOTDONE for directory (failure), or OK
214214
*/
215215
int
216216
readfile(
@@ -450,13 +450,18 @@ readfile(
450450
# endif
451451
)
452452
{
453+
int retval = FAIL;
454+
453455
if (S_ISDIR(perm))
456+
{
454457
filemess(curbuf, fname, (char_u *)_("is a directory"), 0);
458+
retval = NOTDONE;
459+
}
455460
else
456461
filemess(curbuf, fname, (char_u *)_("is not a file"), 0);
457462
msg_end();
458463
msg_scroll = msg_save;
459-
return FAIL;
464+
return retval;
460465
}
461466
#endif
462467
#if defined(MSWIN)
@@ -7174,7 +7179,7 @@ buf_reload(buf_T *buf, int orig_mode)
71747179
#endif
71757180
if (readfile(buf->b_ffname, buf->b_fname, (linenr_T)0,
71767181
(linenr_T)0,
7177-
(linenr_T)MAXLNUM, &ea, flags) == FAIL)
7182+
(linenr_T)MAXLNUM, &ea, flags) != OK)
71787183
{
71797184
#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
71807185
if (!aborting())

src/memline.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ ml_recover(void)
15191519
line_count = pp->pb_pointer[idx].pe_line_count;
15201520
if (readfile(curbuf->b_ffname, NULL, lnum,
15211521
pp->pb_pointer[idx].pe_old_lnum - 1,
1522-
line_count, NULL, 0) == FAIL)
1522+
line_count, NULL, 0) != OK)
15231523
cannot_open = TRUE;
15241524
else
15251525
lnum += line_count;

src/testdir/Make_all.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ NEW_TESTS = test_arglist.res \
144144
test_channel.res \
145145
test_charsearch.res \
146146
test_cmdline.res \
147+
test_command_count.res \
147148
test_crypt.res \
148149
test_cscope.res \
149150
test_diffmode.res \

src/testdir/test_alot.vim

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
source test_assign.vim
55
source test_autocmd.vim
6-
source test_command_count.vim
76
source test_cursor_func.vim
87
source test_delete.vim
98
source test_execute_func.vim

src/testdir/test_autocmd.vim

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,3 +322,22 @@ func Test_three_windows()
322322
call delete('Xtestje2')
323323
call delete('Xtestje3')
324324
endfunc
325+
326+
func Test_BufEnter()
327+
au! BufEnter
328+
au Bufenter * let val = val . '+'
329+
let g:val = ''
330+
split NewFile
331+
call assert_equal('+', g:val)
332+
bwipe!
333+
call assert_equal('++', g:val)
334+
335+
" Also get BufEnter when editing a directory
336+
call mkdir('Xdir')
337+
split Xdir
338+
call assert_equal('+++', g:val)
339+
bwipe!
340+
341+
call delete('Xdir', 'd')
342+
au! BufEnter
343+
endfunc

src/version.c

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

780780
static int included_patches[] =
781781
{ /* Add new patch number below this line */
782+
/**/
783+
178,
784+
/**/
785+
177,
782786
/**/
783787
176,
784788
/**/

0 commit comments

Comments
 (0)