]> granicus.if.org Git - vim/commitdiff
patch 8.2.4154: ml_get error when exchanging windows in Visual mode v8.2.4154
authorBram Moolenaar <Bram@vim.org>
Thu, 20 Jan 2022 13:32:50 +0000 (13:32 +0000)
committerBram Moolenaar <Bram@vim.org>
Thu, 20 Jan 2022 13:32:50 +0000 (13:32 +0000)
Problem:    ml_get error when exchanging windows in Visual mode.
Solution:   Correct end of Visual area when entering another buffer.

src/testdir/test_visual.vim
src/version.c
src/window.c

index a187aa8e085e7554d44308f1231de0d15dca7578..72f5388b934dfd1b013a883cec1eacfb09105597 100644 (file)
@@ -1318,5 +1318,15 @@ func Test_visual_block_insert_round_off()
   bwipe!
 endfunc
 
+" this was causing an ml_get error
+func Test_visual_exchange_windows()
+  enew!
+  new
+  call setline(1, ['foo', 'bar'])
+  exe "normal G\<C-V>gg\<C-W>\<C-X>OO\<Esc>"
+  bwipe!
+  bwipe!
+endfunc
+
 
 " vim: shiftwidth=2 sts=2 expandtab
index 54a9ebee55c393538937fa0e5df2037c37a9e88b..e32abbb79af823c506e984da98cd9abbdcabb65f 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4154,
 /**/
     4153,
 /**/
index 05e85baf366a8c5aa8415424ee61a65852c59b24..74257275c7c3a0270e3743b6ea95cfcf7493b42c 100644 (file)
@@ -1691,6 +1691,11 @@ win_exchange(long Prenum)
 
     (void)win_comp_pos();              // recompute window positions
 
+    if (wp->w_buffer != curbuf)
+       reset_VIsual_and_resel();
+    else if (VIsual_active)
+       wp->w_cursor = curwin->w_cursor;
+
     win_enter(wp, TRUE);
     redraw_all_later(NOT_VALID);
 }
@@ -5332,7 +5337,7 @@ frame_remove(frame_T *frp)
 win_alloc_lines(win_T *wp)
 {
     wp->w_lines_valid = 0;
-    wp->w_lines = ALLOC_CLEAR_MULT(wline_T, Rows );
+    wp->w_lines = ALLOC_CLEAR_MULT(wline_T, Rows);
     if (wp->w_lines == NULL)
        return FAIL;
     return OK;