diff src/buffer.c @ 10154:4647267906cc v7.4.2347

commit https://github.com/vim/vim/commit/c4a908e83690844b0d3a46124ba6af7d23485d69 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Sep 8 23:35:30 2016 +0200 patch 7.4.2347 Problem: Crash when closing a buffer while Visual mode is active. (Dominique Pelle) Solution: Adjust the position before computing the number of lines. When closing the current buffer stop Visual mode.
author Christian Brabandt <cb@256bit.org>
date Thu, 08 Sep 2016 23:45:06 +0200
parents 5d77565e6222
children f1ad88f3834c
line wrap: on
line diff
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -578,6 +578,11 @@ aucmd_abort:
     if (buf->b_ffname == NULL)
 	del_buf = TRUE;
 
+    /* When closing the current buffer stop Visual mode before freeing
+     * anything. */
+    if (buf == curbuf)
+	end_visual_mode();
+
     /*
      * Free all things allocated for this buffer.
      * Also calls the "BufDelete" autocommands when del_buf is TRUE.
@@ -1379,6 +1384,10 @@ do_buffer(
 	    }
 	}
 
+	/* When closing the current buffer stop Visual mode. */
+	if (buf == curbuf)
+	    end_visual_mode();
+
 	/*
 	 * If deleting the last (listed) buffer, make it empty.
 	 * The last (listed) buffer cannot be unloaded.