diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-04-07 23:26:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-07 23:26:03 +0800 |
commit | 1edca3872e7c80a5396b84ffddb879cc18633d56 (patch) | |
tree | d7aa63433f5ec81b7fe113812fbb207b9c95bdc8 /src/nvim/edit.c | |
parent | abc157a6fd5ed2f09271ee3dd75d23d9ec3e0313 (diff) | |
download | rneovim-1edca3872e7c80a5396b84ffddb879cc18633d56.tar.gz rneovim-1edca3872e7c80a5396b84ffddb879cc18633d56.tar.bz2 rneovim-1edca3872e7c80a5396b84ffddb879cc18633d56.zip |
vim-patch:8.2.4707: redrawing could be a bit more efficient (#18022)
Problem: Redrawing could be a bit more efficient.
Solution: Optimize redrawing. (closes vim/vim#10105)
https://github.com/vim/vim/commit/8c9796085071950f9a03ca0fe116608e4f86aac2
Diffstat (limited to 'src/nvim/edit.c')
-rw-r--r-- | src/nvim/edit.c | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c index da0b577056..3ab176b2a3 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -390,12 +390,9 @@ static void insert_enter(InsertState *s) trigger_modechanged(); stop_insert_mode = false; - // 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(get_cursor_pos_ptr()) > 1) { - curwin->w_valid &= ~VALID_VIRTCOL; - curs_columns(curwin, 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'. @@ -7330,21 +7327,21 @@ static void mb_replace_pop_ins(int cc) // Not a multi-byte char, put it back. replace_push(c); break; + } + + buf[0] = c; + assert(n > 1); + 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; - assert(n > 1); - 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; } } } @@ -8054,8 +8051,10 @@ static bool ins_esc(long *count, int cmdchar, bool nomove) 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(); ui_cursor_shape(); // may show different cursor shape |