]> granicus.if.org Git - vim/commitdiff
patch 8.1.0923: terminal dump diff swap does not update file names v8.1.0923
authorBram Moolenaar <Bram@vim.org>
Thu, 14 Feb 2019 23:16:13 +0000 (00:16 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 14 Feb 2019 23:16:13 +0000 (00:16 +0100)
Problem:    Terminal dump diff swap does not update file names.
Solution:   Also swap the file name.  Add a test.

src/terminal.c
src/testdir/test_terminal.vim
src/version.c

index e2ae2f600fa06100e861ec699bcd2476243a95ad..714cb2bcbdbca2494574600a9922b16640bae51d 100644 (file)
@@ -4816,7 +4816,7 @@ term_swap_diff()
     bot_start = line_count - bot_rows;
     sb_line = (sb_line_T *)term->tl_scrollback.ga_data;
 
-    /* move lines from top to above the bottom part */
+    // move lines from top to above the bottom part
     for (lnum = 1; lnum <= top_rows; ++lnum)
     {
        p = vim_strsave(ml_get(1));
@@ -4827,7 +4827,7 @@ term_swap_diff()
        vim_free(p);
     }
 
-    /* move lines from bottom to the top */
+    // move lines from bottom to the top
     for (lnum = 1; lnum <= bot_rows; ++lnum)
     {
        p = vim_strsave(ml_get(bot_start + lnum));
@@ -4838,6 +4838,22 @@ term_swap_diff()
        vim_free(p);
     }
 
+    // move top title to bottom
+    p = vim_strsave(ml_get(bot_rows + 1));
+    if (p == NULL)
+       return OK;
+    ml_append(line_count - top_rows - 1, p, 0, FALSE);
+    ml_delete(bot_rows + 1, FALSE);
+    vim_free(p);
+
+    // move bottom title to top
+    p = vim_strsave(ml_get(line_count - top_rows));
+    if (p == NULL)
+       return OK;
+    ml_delete(line_count - top_rows, FALSE);
+    ml_append(bot_rows, p, 0, FALSE);
+    vim_free(p);
+
     if (top_rows == bot_rows)
     {
        /* rows counts are equal, can swap cell properties */
index 9529b764c804e52e5832d23790815e710070b1dd..4bac4f93c1365ebad1a46b8292de8f99ded67c6a 100644 (file)
@@ -1124,6 +1124,24 @@ func Test_terminal_dumpdiff()
   quit
 endfunc
 
+func Test_terminal_dumpdiff_swap()
+  call assert_equal(1, winnr('$'))
+  call term_dumpdiff('dumps/Test_popup_command_01.dump', 'dumps/Test_popup_command_03.dump')
+  call assert_equal(2, winnr('$'))
+  call assert_equal(62, line('$'))
+  call assert_match('Test_popup_command_01.dump', getline(21))
+  call assert_match('Test_popup_command_03.dump', getline(42))
+  call assert_match('Undo', getline(3))
+  call assert_match('three four five', getline(45))
+
+  normal s
+  call assert_match('Test_popup_command_03.dump', getline(21))
+  call assert_match('Test_popup_command_01.dump', getline(42))
+  call assert_match('three four five', getline(3))
+  call assert_match('Undo', getline(45))
+  quit
+endfunc
+
 func Test_terminal_dumpdiff_options()
   set laststatus=0
   call assert_equal(1, winnr('$'))
index bf47f97b383de25426fc726db18e947b3bfac9e8..bb5e0e1dba78b14b6d44dc145c644bfc5af31c69 100644 (file)
@@ -783,6 +783,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    923,
 /**/
     922,
 /**/