changeset 18372:11394af51615 v8.1.2180

patch 8.1.2180: Error E303 is not useful when 'directory' is empty Commit: https://github.com/vim/vim/commit/00e192becd50a38cb21a1bc3f86fcc7a21f8ee88 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Oct 19 17:01:28 2019 +0200 patch 8.1.2180: Error E303 is not useful when 'directory' is empty Problem: Error E303 is not useful when 'directory' is empty. Solution: Skip the error message. (Daniel Hahler, https://github.com/vim/vim/issues/5067)
author Bram Moolenaar <Bram@vim.org>
date Sat, 19 Oct 2019 17:15:03 +0200
parents d37561c8c48b
children 76e7c6c09dcf
files runtime/doc/message.txt runtime/doc/options.txt src/memline.c src/testdir/test_recover.vim src/version.c
diffstat 5 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/message.txt
+++ b/runtime/doc/message.txt
@@ -582,7 +582,8 @@ allowed for the command that was used.
 Vim was not able to create a swap file.  You can still edit the file, but if
 Vim unexpectedly exits the changes will be lost.  And Vim may consume a lot of
 memory when editing a big file.  You may want to change the 'directory' option
-to avoid this error.  See |swap-file|.
+to avoid this error.  This error is not given when 'directory' is empty.  See
+|swap-file|.
 
 							*E140*  >
   Use ! to write partial buffer
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -2693,7 +2693,7 @@ A jump table for the options with a shor
 	- The swap file will be created in the first directory where this is
 	  possible.
 	- Empty means that no swap file will be used (recovery is
-	  impossible!).
+	  impossible!) and no |E303| error will be given.
 	- A directory "." means to put the swap file in the same directory as
 	  the edited file.  On Unix, a dot is prepended to the file name, so
 	  it doesn't show in a directory listing.  On MS-Windows the "hidden"
--- a/src/memline.c
+++ b/src/memline.c
@@ -804,9 +804,9 @@ ml_open_file(buf_T *buf)
 	}
     }
 
-    if (mfp->mf_fname == NULL)		/* Failed! */
+    if (*p_dir != NUL && mfp->mf_fname == NULL)
     {
-	need_wait_return = TRUE;	/* call wait_return later */
+	need_wait_return = TRUE;	// call wait_return later
 	++no_wait_return;
 	(void)semsg(_("E303: Unable to open swap file for \"%s\", recovery impossible"),
 		    buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname);
--- a/src/testdir/test_recover.vim
+++ b/src/testdir/test_recover.vim
@@ -12,6 +12,12 @@ func Test_recover_root_dir()
     set dir=/notexist/
   endif
   call assert_fails('split Xtest', 'E303:')
+
+  " No error with empty 'directory' setting.
+  set directory=
+  split XtestOK
+  close!
+
   set dir&
 endfunc
 
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2180,
+/**/
     2179,
 /**/
     2178,