diff src/buffer.c @ 29716:c8c128b0eddc v9.0.0198

patch 9.0.0198: ml_get error when switching buffer in Visual mode Commit: https://github.com/vim/vim/commit/cfeb8a584be11758cf71ae02f6c937b06d6bb66f Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 13 14:09:44 2022 +0100 patch 9.0.0198: ml_get error when switching buffer in Visual mode Problem: ml_get error when switching buffer in Visual mode. Solution: End Visual mode when switching buffer. (closes https://github.com/vim/vim/issues/10902)
author Bram Moolenaar <Bram@vim.org>
date Sat, 13 Aug 2022 15:15:03 +0200
parents d3058719eff5
children 89e1d67814a9
line wrap: on
line diff
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1818,6 +1818,14 @@ set_curbuf(buf_T *buf, int action)
     static void
 enter_buffer(buf_T *buf)
 {
+    // when closing the current buffer stop Visual mode
+    if (VIsual_active
+#if defined(EXITFREE)
+	    && !entered_free_all_mem
+#endif
+	    )
+	end_visual_mode();
+
     // Get the buffer in the current window.
     curwin->w_buffer = buf;
     curbuf = buf;