From 008154954791001efcc46c28146e21403f3a698b Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 21 Aug 2023 14:52:17 +0200 Subject: refactor(change): do API changes to buffer without curbuf switch Most of the messy things when changing a non-current buffer is not about the buffer, it is about windows. In particular, it is about `curwin`. When editing a non-current buffer which is displayed in some other window in the current tabpage, one such window will be "borrowed" as the curwin. But this means if two or more non-current windows displayed the buffers, one of them will be treated differenty. this is not desirable. In particular, with nvim_buf_set_text, cursor _column_ position was only corrected for one single window. Two new tests are added: the test with just one non-current window passes, but the one with two didn't. Two corresponding such tests were also added for nvim_buf_set_lines. This already worked correctly on master, but make sure this is well-tested for future refactors. Also, nvim_create_buf no longer invokes autocmds just because you happened to use `scratch=true`. No option value was changed, therefore OptionSet must not be fired. --- src/nvim/window.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index 6ff9e07260..970027b2f8 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -562,7 +562,7 @@ wingotofile: if (wp != NULL && nchar == 'F' && lnum >= 0) { curwin->w_cursor.lnum = lnum; - check_cursor_lnum(); + check_cursor_lnum(curwin); beginline(BL_SOL | BL_FIX); } xfree(ptr); @@ -6493,7 +6493,7 @@ void win_fix_scroll(int resize) wp->w_valid &= ~VALID_CROW; } - invalidate_botline_win(wp); + invalidate_botline(wp); validate_botline(wp); } wp->w_prev_height = wp->w_height; @@ -6666,7 +6666,7 @@ void scroll_to_fraction(win_T *wp, int prev_height) } redraw_later(wp, UPD_SOME_VALID); - invalidate_botline_win(wp); + invalidate_botline(wp); } void win_set_inner_size(win_T *wp, bool valid_cursor) @@ -6713,7 +6713,7 @@ void win_set_inner_size(win_T *wp, bool valid_cursor) wp->w_lines_valid = 0; if (valid_cursor) { changed_line_abv_curs_win(wp); - invalidate_botline_win(wp); + invalidate_botline(wp); if (wp == curwin && *p_spk == 'c') { curs_columns(wp, true); // validate w_wrow } -- cgit