patch 9.1.0083: Redrawing can be improved when deleting lines with 'number'

Commit: 
https://github.com/vim/vim/commit/ae07ebc04b0726e12b1af39d52e01d86ae79ef0a
Author: zeertzjq <[email protected]>
Date:   Thu Feb 8 11:37:40 2024 +0100

    patch 9.1.0083: Redrawing can be improved when deleting lines with 'number'
    
    Problem:  Redrawing can be improved when inserting/deleting lines with 
'number'.
    Solution: Only redraw the number column of lines below changed lines.
              Add a test as this wasn't previously tested.
              (zeertzjq)
    
    closes: #13985
    
    Signed-off-by: zeertzjq <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/drawscreen.c b/src/drawscreen.c
index 960bd6911..d1773701d 100644
--- a/src/drawscreen.c
+++ b/src/drawscreen.c
@@ -1699,11 +1699,6 @@ win_update(win_T *wp)
                top_end = 1;
 #endif
        }
-
-       // When line numbers are displayed need to redraw all lines below
-       // inserted/deleted lines.
-       if (mod_top != 0 && buf->b_mod_xlines != 0 && wp->w_p_nu)
-           mod_bot = MAXLNUM;
     }
     wp->w_redraw_top = 0;      // reset for next time
     wp->w_redraw_bot = 0;
@@ -2540,11 +2535,16 @@ win_update(win_T *wp)
        }
        else
        {
-           if (wp->w_p_rnu && wp->w_last_cursor_lnum_rnu != wp->w_cursor.lnum)
+           // If:
+           // - 'number' is set and below inserted/deleted lines, or
+           // - 'relativenumber' is set and cursor moved vertically,
+           // the text doesn't need to be redrawn, but the number column does.
+           if ((wp->w_p_nu && mod_top != 0
+                       && lnum >= mod_bot && buf->b_mod_xlines != 0)
+                   || (wp->w_p_rnu
+                       && wp->w_last_cursor_lnum_rnu != wp->w_cursor.lnum))
            {
 #ifdef FEAT_FOLDING
-               // 'relativenumber' set and the cursor moved vertically: The
-               // text doesn't need to be drawn, but the number column does.
                fold_count = foldedCount(wp, lnum, &win_foldinfo);
                if (fold_count != 0)
                    fold_line(wp, fold_count, &win_foldinfo, lnum, row);
diff --git a/src/testdir/dumps/Test_number_insert_delete_lines_1.dump 
b/src/testdir/dumps/Test_number_insert_delete_lines_1.dump
new file mode 100644
index 000000000..5aecb46a3
--- /dev/null
+++ b/src/testdir/dumps/Test_number_insert_delete_lines_1.dump
@@ -0,0 +1,8 @@
+| +0#af5f00255#ffffff0@1|1| |1+0#0000000&| @69
+| +0#af5f00255&@1|2| >2+0#0000000&| @69
+| +0#af5f00255&@1|3| |3+0#0000000&| @69
+| +0#af5f00255&@1|4| |4+0#0000000&| @69
+| +0#af5f00255&@1|5| |5+0#0000000&| @69
+| +0#af5f00255&@1|6| |6+0#0000000&| @69
+| +0#af5f00255&@1|7| |7+0#0000000&| @69
+@57|2|,|1| @10|A|l@1| 
diff --git a/src/testdir/dumps/Test_number_insert_delete_lines_2.dump 
b/src/testdir/dumps/Test_number_insert_delete_lines_2.dump
new file mode 100644
index 000000000..dea68e8d0
--- /dev/null
+++ b/src/testdir/dumps/Test_number_insert_delete_lines_2.dump
@@ -0,0 +1,8 @@
+| +0#af5f00255#ffffff0@1|1| |1+0#0000000&| @69
+| +0#af5f00255&@1|2| >3+0#0000000&| @69
+| +0#af5f00255&@1|3| |4+0#0000000&| @69
+| +0#af5f00255&@1|4| |5+0#0000000&| @69
+| +0#af5f00255&@1|5| |6+0#0000000&| @69
+| +0#af5f00255&@1|6| |7+0#0000000&| @69
+|~+0#4040ff13&| @73
+| +0#0000000&@56|2|,|1| @10|A|l@1| 
diff --git a/src/testdir/dumps/Test_number_insert_delete_lines_3.dump 
b/src/testdir/dumps/Test_number_insert_delete_lines_3.dump
new file mode 100644
index 000000000..fff32971e
--- /dev/null
+++ b/src/testdir/dumps/Test_number_insert_delete_lines_3.dump
@@ -0,0 +1,8 @@
+| +0#af5f00255#ffffff0@1|1| |1+0#0000000&| @69
+| +0#af5f00255&@1|2| >4+0#0000000&| @69
+| +0#af5f00255&@1|3| |5+0#0000000&| @69
+| +0#af5f00255&@1|4| |6+0#0000000&| @69
+| +0#af5f00255&@1|5| |7+0#0000000&| @69
+|~+0#4040ff13&| @73
+|~| @73
+| +0#0000000&@56|2|,|1| @10|A|l@1| 
diff --git a/src/testdir/test_number.vim b/src/testdir/test_number.vim
index 6ac3c4cfe..b57c1ed2c 100644
--- a/src/testdir/test_number.vim
+++ b/src/testdir/test_number.vim
@@ -146,8 +146,7 @@ func Test_number_with_linewrap1()
   call s:close_windows()
 endfunc
 
-" Pending: https://groups.google.com/forum/#!topic/vim_dev/tzNKP7EDWYI
-func XTest_number_with_linewrap2()
+func Test_number_with_linewrap2()
   call s:test_windows(3, 20)
   normal! 61ia
   setl number wrap
@@ -164,8 +163,7 @@ func XTest_number_with_linewrap2()
   call s:close_windows()
 endfunc
 
-" Pending: https://groups.google.com/forum/#!topic/vim_dev/tzNKP7EDWYI
-func XTest_number_with_linewrap3()
+func Test_number_with_linewrap3()
   call s:test_windows(4, 20)
   normal! 81ia
   setl number wrap
@@ -174,7 +172,7 @@ func XTest_number_with_linewrap3()
   call s:validate_cursor()
   let lines = s:screen_lines(1, 4)
   let expect = [
-\ "aaaaaaaa",
+\ "<<<aaaaa",
 \ "aaaaaaaa",
 \ "aaaaaaaa",
 \ "a       ",
@@ -349,6 +347,31 @@ func Test_relativenumber_callback()
   call StopVimInTerminal(buf)
 endfunc
 
+" Test that line numbers below inserted/deleted lines are updated.
+func Test_number_insert_delete_lines()
+  CheckScreendump
+
+  let lines =<< trim END
+      call setline(1, range(1, 7))
+      set number
+      call cursor(2, 1)
+  END
+  call writefile(lines, 'Xnumber_insert_delete_lines', 'D')
+
+  let buf = RunVimInTerminal('-S Xnumber_insert_delete_lines', #{rows: 8})
+  call VerifyScreenDump(buf, 'Test_number_insert_delete_lines_1', {})
+  call term_sendkeys(buf, "dd")
+  call VerifyScreenDump(buf, 'Test_number_insert_delete_lines_2', {})
+  call term_sendkeys(buf, "P")
+  call VerifyScreenDump(buf, 'Test_number_insert_delete_lines_1', {})
+  call term_sendkeys(buf, "2dd")
+  call VerifyScreenDump(buf, 'Test_number_insert_delete_lines_3', {})
+  call term_sendkeys(buf, "P")
+  call VerifyScreenDump(buf, 'Test_number_insert_delete_lines_1', {})
+
+  call StopVimInTerminal(buf)
+endfunc
+
 " Test for displaying line numbers with 'rightleft'
 func Test_number_rightleft()
   CheckFeature rightleft
diff --git a/src/version.c b/src/version.c
index 7e07e66f5..e0f30f232 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    83,
 /**/
     82,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/E1rY1tw-002zWp-Sm%40256bit.org.

Raspunde prin e-mail lui