diff src/fileio.c @ 837:6bb1fa855dc9 v7.0e03

updated for version 7.0e03
author vimboss
date Wed, 19 Apr 2006 21:23:36 +0000
parents 5a7843c57316
children d3bbb5dd3913
line wrap: on
line diff
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -6482,7 +6482,7 @@ buf_reload(buf, orig_mode)
 	{
 	    /* Allocate a buffer without putting it in the buffer list. */
 	    savebuf = buflist_new(NULL, NULL, (linenr_T)1, BLN_DUMMY);
-	    if (savebuf != NULL)
+	    if (savebuf != NULL && buf == curbuf)
 	    {
 		/* Open the memline. */
 		curbuf = savebuf;
@@ -6491,7 +6491,7 @@ buf_reload(buf, orig_mode)
 		curbuf = buf;
 		curwin->w_buffer = buf;
 	    }
-	    if (savebuf == NULL || saved == FAIL
+	    if (savebuf == NULL || saved == FAIL || buf != curbuf
 				      || move_lines(buf, savebuf) == FAIL)
 	    {
 		EMSG2(_("E462: Could not prepare for reloading \"%s\""),
@@ -6514,18 +6514,17 @@ buf_reload(buf, orig_mode)
 		if (!aborting())
 #endif
 		    EMSG2(_("E321: Could not reload \"%s\""), buf->b_fname);
-		if (savebuf != NULL)
+		if (savebuf != NULL && buf_valid(savebuf) && buf == curbuf)
 		{
 		    /* Put the text back from the save buffer.  First
 		     * delete any lines that readfile() added. */
 		    while (!bufempty())
-			if (ml_delete(curbuf->b_ml.ml_line_count, FALSE)
-								  == FAIL)
+			if (ml_delete(buf->b_ml.ml_line_count, FALSE) == FAIL)
 			    break;
 		    (void)move_lines(savebuf, buf);
 		}
 	    }
-	    else
+	    else if (buf == curbuf)
 	    {
 		/* Mark the buffer as unmodified and free undo info. */
 		unchanged(buf, TRUE);
@@ -6535,12 +6534,12 @@ buf_reload(buf, orig_mode)
 	}
 	vim_free(ea.cmd);
 
-	if (savebuf != NULL)
+	if (savebuf != NULL && buf_valid(savebuf))
 	    wipe_buffer(savebuf, FALSE);
 
 #ifdef FEAT_DIFF
 	/* Invalidate diff info if necessary. */
-	diff_invalidate(buf);
+	diff_invalidate(curbuf);
 #endif
 
 	/* Restore the topline and cursor position and check it (lines may