From 0f078bdde8aea9424281206ea96b4626ce6ff944 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Sun, 4 Oct 2020 11:34:50 +0900 Subject: vim-patch:8.2.1793: not consistently giving the "is a directory" warning Problem: Not consistently giving the "is a directory" warning. Solution: Adjust check for illegal file name and directory. (Yasuhiro Matsumoto, closes vim/vim#7067) https://github.com/vim/vim/commit/c8fe645c198e2ca55c4e3446efbbdb9b995c63ce --- src/nvim/testdir/check.vim | 16 ++++++++++++++++ src/nvim/testdir/test_edit.vim | 27 +++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/check.vim b/src/nvim/testdir/check.vim index e0ebe8fd49..b96026c5c0 100644 --- a/src/nvim/testdir/check.vim +++ b/src/nvim/testdir/check.vim @@ -73,3 +73,19 @@ func CheckNotGui() throw 'Skipped: only works in the terminal' endif 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 diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim index 7f456ffbce..97a8ad25a3 100644 --- a/src/nvim/testdir/test_edit.vim +++ b/src/nvim/testdir/test_edit.vim @@ -1534,3 +1534,30 @@ func Test_edit_noesckeys() bwipe! " set esckeys 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 -- cgit