Skip to content

Commit 40fa12a

Browse files
committed
patch 8.2.3453: autocmd not executed when editing a directory
Problem: Autocmd not executed when editing a directory ending in a path separator inside try block. Solution: Return NOTDONE instead of FAIL. (closes #8885)
1 parent da0b497 commit 40fa12a

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/fileio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ readfile(
338338
filemess(curbuf, fname, (char_u *)_(msg_is_a_directory), 0);
339339
msg_end();
340340
msg_scroll = msg_save;
341-
return FAIL;
341+
return NOTDONE;
342342
}
343343
}
344344

src/testdir/test_autocmd.vim

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2346,6 +2346,19 @@ func Test_throw_in_BufWritePre()
23462346
au! throwing
23472347
endfunc
23482348

2349+
func Test_autocmd_in_try_block()
2350+
call mkdir('Xdir')
2351+
au BufEnter * let g:fname = expand('%')
2352+
try
2353+
edit Xdir/
2354+
endtry
2355+
call assert_match('Xdir', g:fname)
2356+
2357+
unlet g:fname
2358+
au! BufEnter
2359+
call delete('Xdir', 'rf')
2360+
endfunc
2361+
23492362
func Test_autocmd_SafeState()
23502363
CheckRunVimInTerminal
23512364

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,8 @@ static char *(features[]) =
757757

758758
static int included_patches[] =
759759
{ /* Add new patch number below this line */
760+
/**/
761+
3453,
760762
/**/
761763
3452,
762764
/**/

0 commit comments

Comments
 (0)