diff options
Diffstat (limited to 'src/nvim/edit.c')
-rw-r--r-- | src/nvim/edit.c | 65 |
1 files changed, 22 insertions, 43 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c index bb3c0ec196..62b35fa708 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -473,6 +473,8 @@ static void insert_enter(InsertState *s) o_lnum = curwin->w_cursor.lnum; } + pum_check_clear(); + foldUpdateAfterInsert(); // When CTRL-C was typed got_int will be set, with the result // that the autocommands won't be executed. When mapped got_int @@ -566,7 +568,7 @@ static int insert_check(VimState *state) if (curwin->w_wcol < s->mincol - curbuf->b_p_ts && curwin->w_wrow == curwin->w_winrow - + curwin->w_grid.Rows - 1 - p_so + + curwin->w_height_inner - 1 - p_so && (curwin->w_cursor.lnum != curwin->w_topline || curwin->w_topfill > 0)) { if (curwin->w_topfill > 0) { @@ -1447,6 +1449,7 @@ ins_redraw ( redrawWinline(curwin, curwin->w_cursor.lnum); } + pum_check_clear(); if (must_redraw) { update_screen(0); } else if (clear_cmdline || redraw_cmdline) { @@ -2490,20 +2493,6 @@ void set_completion(colnr_T startcol, list_T *list) static pumitem_T *compl_match_array = NULL; static int compl_match_arraysize; -/* - * Update the screen and when there is any scrolling remove the popup menu. - */ -static void ins_compl_upd_pum(void) -{ - int h; - - if (compl_match_array != NULL) { - h = curwin->w_cline_height; - update_screen(0); - if (h != curwin->w_cline_height) - ins_compl_del_pum(); - } -} /* * Remove any popup menu. @@ -2511,7 +2500,7 @@ static void ins_compl_upd_pum(void) static void ins_compl_del_pum(void) { if (compl_match_array != NULL) { - pum_undisplay(); + pum_undisplay(false); xfree(compl_match_array); compl_match_array = NULL; } @@ -4305,17 +4294,14 @@ ins_compl_next ( } if (!allow_get_expansion) { - /* may undisplay the popup menu first */ - ins_compl_upd_pum(); - - /* redraw to show the user what was inserted */ + // redraw to show the user what was inserted update_screen(0); - /* display the updated popup menu */ + // display the updated popup menu ins_compl_show_pum(); - /* Delete old text to be replaced, since we're still searching and - * don't want to match ourselves! */ + // Delete old text to be replaced, since we're still searching and + // don't want to match ourselves! ins_compl_delete(); } @@ -4862,8 +4848,6 @@ static int ins_complete(int c, bool enable_pum) save_w_leftcol = curwin->w_leftcol; n = ins_compl_next(true, ins_compl_key2count(c), insert_match, false); - /* may undisplay the popup menu */ - ins_compl_upd_pum(); if (n > 1) /* all matches have been found */ compl_matches = n; @@ -5868,7 +5852,7 @@ static void check_auto_format( /* * Find out textwidth to be used for formatting: * if 'textwidth' option is set, use it - * else if 'wrapmargin' option is set, use curwin->w_grid.Columns-'wrapmargin' + * else if 'wrapmargin' option is set, use curwin->w_width_inner-'wrapmargin' * if invalid value, use 0. * Set default to window width (maximum 79) for "gq" operator. */ @@ -5883,7 +5867,7 @@ comp_textwidth ( if (textwidth == 0 && curbuf->b_p_wm) { /* The width is the window width minus 'wrapmargin' minus all the * things that add to the margin. */ - textwidth = curwin->w_grid.Columns - curbuf->b_p_wm; + textwidth = curwin->w_width_inner - curbuf->b_p_wm; if (cmdwin_type != 0) { textwidth -= 1; } @@ -5899,7 +5883,7 @@ comp_textwidth ( if (textwidth < 0) textwidth = 0; if (ff && textwidth == 0) { - textwidth = curwin->w_grid.Columns - 1; + textwidth = curwin->w_width_inner - 1; if (textwidth > 79) { textwidth = 79; } @@ -7144,11 +7128,17 @@ static void ins_reg(void) * message for it. Only call it explicitly. */ ++no_u_sync; if (regname == '=') { - /* Sync undo when evaluating the expression calls setline() or - * append(), so that it can be undone separately. */ + pos_T curpos = curwin->w_cursor; + + // Sync undo when evaluating the expression calls setline() or + // append(), so that it can be undone separately. u_sync_once = 2; regname = get_expr_register(); + + // Cursor may be moved back a column. + curwin->w_cursor = curpos; + check_cursor(); } if (regname == NUL || !valid_yank_reg(regname, false)) { vim_beep(BO_REG); @@ -7939,15 +7929,13 @@ static void ins_mouse(int c) static void ins_mousescroll(int dir) { win_T *const old_curwin = curwin; - bool did_scroll = false; pos_T tpos = curwin->w_cursor; if (mouse_row >= 0 && mouse_col >= 0) { - int row = mouse_row; - int col = mouse_col; + int row = mouse_row, col = mouse_col, grid = mouse_grid; // find the window at the pointer coordinates - win_T *const wp = mouse_find_win(&row, &col); + win_T *wp = mouse_find_win(&grid, &row, &col); if (wp == NULL) { return; } @@ -7970,7 +7958,6 @@ static void ins_mousescroll(int dir) } else { mouse_scroll_horiz(dir); } - did_scroll = true; } curwin->w_redr_status = TRUE; @@ -7978,14 +7965,6 @@ static void ins_mousescroll(int dir) curwin = old_curwin; curbuf = curwin->w_buffer; - /* The popup menu may overlay the window, need to redraw it. - * TODO: Would be more efficient to only redraw the windows that are - * overlapped by the popup menu. */ - if (pum_visible() && did_scroll) { - redraw_all_later(NOT_VALID); - ins_compl_show_pum(); - } - if (!equalpos(curwin->w_cursor, tpos)) { start_arrow(&tpos); can_cindent = true; |