diff options
author | solawing <316786359@qq.com> | 2015-05-16 16:51:37 +0800 |
---|---|---|
committer | solawing <316786359@qq.com> | 2016-01-29 22:03:11 +0800 |
commit | b55726b35075148ae29c5ae635e85a11e09e9dfa (patch) | |
tree | ce7f68435b1fbc6a3a3ec8e6e1f0774789593286 /src | |
parent | 4c960c3d78d9aaae77c469c91c88280c9f5efbf2 (diff) | |
download | rneovim-b55726b35075148ae29c5ae635e85a11e09e9dfa.tar.gz rneovim-b55726b35075148ae29c5ae635e85a11e09e9dfa.tar.bz2 rneovim-b55726b35075148ae29c5ae635e85a11e09e9dfa.zip |
edit.c: fix flicker in popup menu
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/edit.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c index dbbcf4f1b9..f0b79110ea 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -2928,11 +2928,16 @@ static void ins_compl_new_leader(void) else { spell_bad_len = 0; /* need to redetect bad word */ /* - * Matches were cleared, need to search for them now. First display - * the changed text before the cursor. Set "compl_restarting" to - * avoid that the first match is inserted. + * Matches were cleared, need to search for them now. + * If it's user complete function and refresh_always, + * not use "compl_leader" as prefix filter. + * Set "compl_restarting" to avoid that the first match is inserted. */ - update_screen(0); + if ((ctrl_x_mode == CTRL_X_FUNCTION || ctrl_x_mode == CTRL_X_OMNI) + && compl_opt_refresh_always){ + xfree(compl_leader); + compl_leader = NULL; + } compl_restarting = TRUE; if (ins_complete(Ctrl_N) == FAIL) compl_cont_status = 0; @@ -2976,11 +2981,13 @@ static void ins_compl_addleader(int c) (*mb_char2bytes)(c, buf); buf[cc] = NUL; ins_char_bytes(buf, cc); - if (compl_opt_refresh_always) + if ((ctrl_x_mode == CTRL_X_FUNCTION || ctrl_x_mode == CTRL_X_OMNI) + && compl_opt_refresh_always) AppendToRedobuff(buf); } else { ins_char(c); - if (compl_opt_refresh_always) + if ((ctrl_x_mode == CTRL_X_FUNCTION || ctrl_x_mode == CTRL_X_OMNI) + && compl_opt_refresh_always) AppendCharToRedobuff(c); } @@ -2988,15 +2995,10 @@ static void ins_compl_addleader(int c) if (ins_compl_need_restart()) ins_compl_restart(); - /* When 'always' is set, don't reset compl_leader. While completing, - * cursor doesn't point original position, changing compl_leader would - * break redo. */ - if (!compl_opt_refresh_always) { - xfree(compl_leader); - compl_leader = vim_strnsave(get_cursor_line_ptr() + compl_col, - (int)(curwin->w_cursor.col - compl_col)); - ins_compl_new_leader(); - } + xfree(compl_leader); + compl_leader = vim_strnsave(get_cursor_line_ptr() + compl_col, + (int)(curwin->w_cursor.col - compl_col)); + ins_compl_new_leader(); } /* @@ -3005,6 +3007,10 @@ static void ins_compl_addleader(int c) */ static void ins_compl_restart(void) { + /* update screen before restart. + * so if complete is blocked, + * will stay to the last popup menu and reduce flick */ + update_screen(0); ins_compl_free(); compl_started = FALSE; compl_matches = 0; |