]> granicus.if.org Git - vim/commitdiff
patch 8.2.4707: redrawing could be a bit more efficient v8.2.4707
authorzeertzjq <zeertzjq@outlook.com>
Thu, 7 Apr 2022 14:08:01 +0000 (15:08 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 7 Apr 2022 14:08:01 +0000 (15:08 +0100)
Problem:    Redrawing could be a bit more efficient.
Solution:   Optimize redrawing. (closes #10105)

src/change.c
src/edit.c
src/testdir/dumps/Test_cursorcolumn_insert_on_tab_3.dump [new file with mode: 0644]
src/testdir/test_highlight.vim
src/version.c

index afc32b7241ca112a8af3d69bda709deea9616c91..bc9195be445725086457f0e8efaef5b296840320 100644 (file)
@@ -640,9 +640,13 @@ changed_common(
            if (hasAnyFolding(wp))
                set_topline(wp, wp->w_topline);
 #endif
-           // Relative numbering may require updating more.
+           // If lines have been added or removed, relative numbering always
+           // requires a redraw.
            if (wp->w_p_rnu && xtra != 0)
-               redraw_win_later(wp, SOME_VALID);
+           {
+               wp->w_last_cursor_lnum_rnu = 0;
+               redraw_win_later(wp, VALID);
+           }
 #ifdef FEAT_SYN_HL
            // Cursor line highlighting probably need to be updated with
            // "VALID" if it's below the change.
index c52583a8b6f8076680c8221a8e08ecf5f3f50b20..53e86ff18f268228a28332fb541c3146dacdc35c 100644 (file)
@@ -293,14 +293,9 @@ edit(
     conceal_check_cursor_line(cursor_line_was_concealed);
 #endif
 
-    // Need to recompute the cursor position, it might move when the cursor
-    // is on a TAB or special character.
-    // ptr2cells() treats a TAB character as double-width.
-    if (ptr2cells(ml_get_cursor()) > 1)
-    {
-       curwin->w_valid &= ~VALID_VIRTCOL;
-       curs_columns(TRUE);
-    }
+    // need to position cursor again when on a TAB
+    if (gchar_cursor() == TAB)
+       curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL);
 
     /*
      * Enable langmap or IME, indicated by 'iminsert'.
@@ -3149,21 +3144,20 @@ mb_replace_pop_ins(int cc)
                replace_push(c);
                break;
            }
+
+           buf[0] = c;
+           for (i = 1; i < n; ++i)
+               buf[i] = replace_pop();
+           if (utf_iscomposing(utf_ptr2char(buf)))
+               ins_bytes_len(buf, n);
            else
            {
-               buf[0] = c;
-               for (i = 1; i < n; ++i)
-                   buf[i] = replace_pop();
-               if (utf_iscomposing(utf_ptr2char(buf)))
-                   ins_bytes_len(buf, n);
-               else
-               {
-                   // Not a composing char, put it back.
-                   for (i = n - 1; i >= 0; --i)
-                       replace_push(buf[i]);
-                   break;
-               }
+               // Not a composing char, put it back.
+               for (i = n - 1; i >= 0; --i)
+                   replace_push(buf[i]);
+               break;
            }
+
        }
 }
 
@@ -3702,8 +3696,9 @@ ins_esc(
 
     State = NORMAL;
     trigger_modechanged();
-    // need to position cursor again (e.g. when on a TAB )
-    changed_cline_bef_curs();
+    // need to position cursor again when on a TAB
+    if (gchar_cursor() == TAB)
+       curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL);
 
     setmouse();
 #ifdef CURSOR_SHAPE
diff --git a/src/testdir/dumps/Test_cursorcolumn_insert_on_tab_3.dump b/src/testdir/dumps/Test_cursorcolumn_insert_on_tab_3.dump
new file mode 100644 (file)
index 0000000..9d0cbed
--- /dev/null
@@ -0,0 +1,8 @@
+|1+0&#ffffff0|2|3|4|5|6|7|8+0&#e0e0e08|9+0&#ffffff0| @65
+|a| @5> |b| @65
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|-+2#0000000&@1| |(|i|n|s|e|r|t|)| |-@1| +0&&@42|2|,|2|-|8| @8|A|l@1| 
index 51a25242feab20a0356ad293de370c4373187263..3400052a7cd0bbc72fb6fe1d9d7ca2fa04a7dc4e 100644 (file)
@@ -610,6 +610,14 @@ func Test_cursorcolumn_insert_on_tab()
   call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_cursorcolumn_insert_on_tab_2', {})
 
+  call term_sendkeys(buf, "\<C-O>")
+  call TermWait(buf)
+  call VerifyScreenDump(buf, 'Test_cursorcolumn_insert_on_tab_3', {})
+
+  call term_sendkeys(buf, 'i')
+  call TermWait(buf)
+  call VerifyScreenDump(buf, 'Test_cursorcolumn_insert_on_tab_2', {})
+
   call StopVimInTerminal(buf)
   call delete('Xcuc_insert_on_tab')
 endfunc
index d0205d7e33d704e0a7df5377853efd3e2b930de6..bd63e9317da7f6be14e9d01a9ab221712edb460f 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4707,
 /**/
     4706,
 /**/