diff options
author | Daniel Hahler <git@thequod.de> | 2019-06-09 15:51:29 +0200 |
---|---|---|
committer | Daniel Hahler <git@thequod.de> | 2019-08-07 14:21:23 +0200 |
commit | 53210c16d197614298bcc3ca675f7ede0cb9caec (patch) | |
tree | 1b4408887bec7d5cb2f7749de7a4d4ff056c4136 /src/nvim/misc1.c | |
parent | 0e5314f56e5891f4f406c038a2bb4bdf8cbf8e6e (diff) | |
download | rneovim-53210c16d197614298bcc3ca675f7ede0cb9caec.tar.gz rneovim-53210c16d197614298bcc3ca675f7ede0cb9caec.tar.bz2 rneovim-53210c16d197614298bcc3ca675f7ede0cb9caec.zip |
move changed_common
Diffstat (limited to 'src/nvim/misc1.c')
-rw-r--r-- | src/nvim/misc1.c | 168 |
1 files changed, 0 insertions, 168 deletions
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index d2d0fbad7d..26ed9169e7 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -1960,174 +1960,6 @@ void changed_lines_buf(buf_T *buf, linenr_T lnum, linenr_T lnume, long xtra) } /* - * Common code for when a change is was made. - * See changed_lines() for the arguments. - * Careful: may trigger autocommands that reload the buffer. - */ -static void changed_common(linenr_T lnum, colnr_T col, linenr_T lnume, long xtra) -{ - int i; - int cols; - pos_T *p; - int add; - - /* mark the buffer as modified */ - changed(); - - if (curwin->w_p_diff && diff_internal()) { - curtab->tp_diff_update = true; - } - - /* set the '. mark */ - if (!cmdmod.keepjumps) { - RESET_FMARK(&curbuf->b_last_change, ((pos_T) {lnum, col, 0}), 0); - - /* Create a new entry if a new undo-able change was started or we - * don't have an entry yet. */ - if (curbuf->b_new_change || curbuf->b_changelistlen == 0) { - if (curbuf->b_changelistlen == 0) - add = TRUE; - else { - /* Don't create a new entry when the line number is the same - * as the last one and the column is not too far away. Avoids - * creating many entries for typing "xxxxx". */ - p = &curbuf->b_changelist[curbuf->b_changelistlen - 1].mark; - if (p->lnum != lnum) - add = TRUE; - else { - cols = comp_textwidth(FALSE); - if (cols == 0) - cols = 79; - add = (p->col + cols < col || col + cols < p->col); - } - } - if (add) { - /* This is the first of a new sequence of undo-able changes - * and it's at some distance of the last change. Use a new - * position in the changelist. */ - curbuf->b_new_change = false; - - if (curbuf->b_changelistlen == JUMPLISTSIZE) { - /* changelist is full: remove oldest entry */ - curbuf->b_changelistlen = JUMPLISTSIZE - 1; - memmove(curbuf->b_changelist, curbuf->b_changelist + 1, - sizeof(curbuf->b_changelist[0]) * (JUMPLISTSIZE - 1)); - FOR_ALL_TAB_WINDOWS(tp, wp) { - /* Correct position in changelist for other windows on - * this buffer. */ - if (wp->w_buffer == curbuf && wp->w_changelistidx > 0) { - --wp->w_changelistidx; - } - } - } - FOR_ALL_TAB_WINDOWS(tp, wp) { - /* For other windows, if the position in the changelist is - * at the end it stays at the end. */ - if (wp->w_buffer == curbuf - && wp->w_changelistidx == curbuf->b_changelistlen) { - ++wp->w_changelistidx; - } - } - ++curbuf->b_changelistlen; - } - } - curbuf->b_changelist[curbuf->b_changelistlen - 1] = - curbuf->b_last_change; - /* The current window is always after the last change, so that "g," - * takes you back to it. */ - curwin->w_changelistidx = curbuf->b_changelistlen; - } - - FOR_ALL_TAB_WINDOWS(tp, wp) { - if (wp->w_buffer == curbuf) { - /* Mark this window to be redrawn later. */ - if (wp->w_redr_type < VALID) - wp->w_redr_type = VALID; - - /* Check if a change in the buffer has invalidated the cached - * values for the cursor. */ - /* - * Update the folds for this window. Can't postpone this, because - * a following operator might work on the whole fold: ">>dd". - */ - foldUpdate(wp, lnum, lnume + xtra - 1); - - /* The change may cause lines above or below the change to become - * included in a fold. Set lnum/lnume to the first/last line that - * might be displayed differently. - * Set w_cline_folded here as an efficient way to update it when - * inserting lines just above a closed fold. */ - bool folded = hasFoldingWin(wp, lnum, &lnum, NULL, false, NULL); - if (wp->w_cursor.lnum == lnum) - wp->w_cline_folded = folded; - folded = hasFoldingWin(wp, lnume, NULL, &lnume, false, NULL); - if (wp->w_cursor.lnum == lnume) - wp->w_cline_folded = folded; - - /* If the changed line is in a range of previously folded lines, - * compare with the first line in that range. */ - if (wp->w_cursor.lnum <= lnum) { - i = find_wl_entry(wp, lnum); - if (i >= 0 && wp->w_cursor.lnum > wp->w_lines[i].wl_lnum) - changed_line_abv_curs_win(wp); - } - - if (wp->w_cursor.lnum > lnum) - changed_line_abv_curs_win(wp); - else if (wp->w_cursor.lnum == lnum && wp->w_cursor.col >= col) - changed_cline_bef_curs_win(wp); - if (wp->w_botline >= lnum) { - /* Assume that botline doesn't change (inserted lines make - * other lines scroll down below botline). */ - approximate_botline_win(wp); - } - - /* Check if any w_lines[] entries have become invalid. - * For entries below the change: Correct the lnums for - * inserted/deleted lines. Makes it possible to stop displaying - * after the change. */ - for (i = 0; i < wp->w_lines_valid; ++i) - if (wp->w_lines[i].wl_valid) { - if (wp->w_lines[i].wl_lnum >= lnum) { - if (wp->w_lines[i].wl_lnum < lnume) { - /* line included in change */ - wp->w_lines[i].wl_valid = FALSE; - } else if (xtra != 0) { - /* line below change */ - wp->w_lines[i].wl_lnum += xtra; - wp->w_lines[i].wl_lastlnum += xtra; - } - } else if (wp->w_lines[i].wl_lastlnum >= lnum) { - /* change somewhere inside this range of folded lines, - * may need to be redrawn */ - wp->w_lines[i].wl_valid = FALSE; - } - } - - /* Take care of side effects for setting w_topline when folds have - * changed. Esp. when the buffer was changed in another window. */ - if (hasAnyFolding(wp)) - set_topline(wp, wp->w_topline); - - // relative numbering may require updating more - if (wp->w_p_rnu) { - redraw_win_later(wp, SOME_VALID); - } - } - } - - /* Call update_screen() later, which checks out what needs to be redrawn, - * since it notices b_mod_set and then uses b_mod_*. */ - if (must_redraw < VALID) - must_redraw = VALID; - - /* when the cursor line is changed always trigger CursorMoved */ - if (lnum <= curwin->w_cursor.lnum - && lnume + (xtra < 0 ? -xtra : xtra) > curwin->w_cursor.lnum) - curwin->w_last_cursormoved.lnum = 0; -} - -/* * unchanged() is called when the changed flag must be reset for buffer 'buf' */ void |