mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #13040 from Shougo/vim-8.2.1793
[RDY] vim-patch:8.2.1793: not consistently giving the "is a directory" warning
This commit is contained in:
commit
c76fc7942b
@ -350,6 +350,7 @@ readfile(
|
|||||||
char_u *old_b_fname;
|
char_u *old_b_fname;
|
||||||
int using_b_ffname;
|
int using_b_ffname;
|
||||||
int using_b_fname;
|
int using_b_fname;
|
||||||
|
static char *msg_is_a_directory = N_("is a directory");
|
||||||
|
|
||||||
au_did_filetype = false; // reset before triggering any autocommands
|
au_did_filetype = false; // reset before triggering any autocommands
|
||||||
|
|
||||||
@ -444,16 +445,27 @@ readfile(
|
|||||||
else
|
else
|
||||||
msg_scroll = TRUE; /* don't overwrite previous file message */
|
msg_scroll = TRUE; /* don't overwrite previous file message */
|
||||||
|
|
||||||
/*
|
// If the name is too long we might crash further on, quit here.
|
||||||
* If the name is too long we might crash further on, quit here.
|
|
||||||
*/
|
|
||||||
if (fname != NULL && *fname != NUL) {
|
if (fname != NULL && *fname != NUL) {
|
||||||
if (STRLEN(fname) >= MAXPATHL) {
|
size_t namelen = STRLEN(fname);
|
||||||
|
|
||||||
|
// If the name is too long we might crash further on, quit here.
|
||||||
|
if (namelen >= MAXPATHL) {
|
||||||
filemess(curbuf, fname, (char_u *)_("Illegal file name"), 0);
|
filemess(curbuf, fname, (char_u *)_("Illegal file name"), 0);
|
||||||
msg_end();
|
msg_end();
|
||||||
msg_scroll = msg_save;
|
msg_scroll = msg_save;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the name ends in a path separator, we can't open it. Check here,
|
||||||
|
// because reading the file may actually work, but then creating the
|
||||||
|
// swap file may destroy it! Reported on MS-DOS and Win 95.
|
||||||
|
if (after_pathsep((const char *)fname, (const char *)(fname + namelen))) {
|
||||||
|
filemess(curbuf, fname, (char_u *)_(msg_is_a_directory), 0);
|
||||||
|
msg_end();
|
||||||
|
msg_scroll = msg_save;
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!read_buffer && !read_stdin && !read_fifo) {
|
if (!read_buffer && !read_stdin && !read_fifo) {
|
||||||
@ -474,7 +486,7 @@ readfile(
|
|||||||
# endif
|
# endif
|
||||||
) {
|
) {
|
||||||
if (S_ISDIR(perm)) {
|
if (S_ISDIR(perm)) {
|
||||||
filemess(curbuf, fname, (char_u *)_("is a directory"), 0);
|
filemess(curbuf, fname, (char_u *)_(msg_is_a_directory), 0);
|
||||||
} else {
|
} else {
|
||||||
filemess(curbuf, fname, (char_u *)_("is not a file"), 0);
|
filemess(curbuf, fname, (char_u *)_("is not a file"), 0);
|
||||||
}
|
}
|
||||||
@ -544,7 +556,7 @@ readfile(
|
|||||||
#ifndef UNIX
|
#ifndef UNIX
|
||||||
// On non-unix systems we can't open a directory, check here.
|
// On non-unix systems we can't open a directory, check here.
|
||||||
if (os_isdir(fname)) {
|
if (os_isdir(fname)) {
|
||||||
filemess(curbuf, sfname, (char_u *)_("is a directory"), 0);
|
filemess(curbuf, sfname, (char_u *)_(msg_is_a_directory), 0);
|
||||||
curbuf->b_p_ro = true; // must use "w!" now
|
curbuf->b_p_ro = true; // must use "w!" now
|
||||||
} else {
|
} else {
|
||||||
#endif
|
#endif
|
||||||
|
@ -73,3 +73,19 @@ func CheckNotGui()
|
|||||||
throw 'Skipped: only works in the terminal'
|
throw 'Skipped: only works in the terminal'
|
||||||
endif
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Command to check that the current language is English
|
||||||
|
command CheckEnglish call CheckEnglish()
|
||||||
|
func CheckEnglish()
|
||||||
|
if v:lang != "C" && v:lang !~ '^[Ee]n'
|
||||||
|
throw 'Skipped: only works in English language environment'
|
||||||
|
endif
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Command to check for NOT running on MS-Windows
|
||||||
|
command CheckNotMSWindows call CheckNotMSWindows()
|
||||||
|
func CheckNotMSWindows()
|
||||||
|
if has('win32')
|
||||||
|
throw 'Skipped: does not work on MS-Windows'
|
||||||
|
endif
|
||||||
|
endfunc
|
||||||
|
@ -1534,3 +1534,30 @@ func Test_edit_noesckeys()
|
|||||||
bwipe!
|
bwipe!
|
||||||
" set esckeys
|
" set esckeys
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for editing a directory
|
||||||
|
" Todo: "is a directory" message is not displayed in Windows.
|
||||||
|
func Test_edit_is_a_directory()
|
||||||
|
CheckEnglish
|
||||||
|
CheckNotMSWindows
|
||||||
|
let dirname = getcwd() . "/Xdir"
|
||||||
|
call mkdir(dirname, 'p')
|
||||||
|
|
||||||
|
new
|
||||||
|
redir => msg
|
||||||
|
exe 'edit' dirname
|
||||||
|
redir END
|
||||||
|
call assert_match("is a directory$", split(msg, "\n")[0])
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
let dirname .= '/'
|
||||||
|
|
||||||
|
new
|
||||||
|
redir => msg
|
||||||
|
exe 'edit' dirname
|
||||||
|
redir END
|
||||||
|
call assert_match("is a directory$", split(msg, "\n")[0])
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
call delete(dirname, 'rf')
|
||||||
|
endfunc
|
||||||
|
Loading…
Reference in New Issue
Block a user