mirror of
https://github.com/neovim/neovim.git
synced 2025-10-02 16:08:36 +00:00
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.
This commit is contained in:
@@ -492,7 +492,7 @@ static void may_do_incsearch_highlighting(int firstc, int count, incsearch_state
|
||||
// first restore the old curwin values, so the screen is
|
||||
// positioned in the same way as the actual search command
|
||||
restore_viewstate(curwin, &s->old_viewstate);
|
||||
changed_cline_bef_curs();
|
||||
changed_cline_bef_curs(curwin);
|
||||
update_topline(curwin);
|
||||
|
||||
if (found != 0) {
|
||||
@@ -1460,7 +1460,7 @@ static int may_do_command_line_next_incsearch(int firstc, int count, incsearch_s
|
||||
|
||||
set_search_match(&s->match_end);
|
||||
curwin->w_cursor = s->match_start;
|
||||
changed_cline_bef_curs();
|
||||
changed_cline_bef_curs(curwin);
|
||||
update_topline(curwin);
|
||||
validate_cursor();
|
||||
highlight_match = true;
|
||||
@@ -4480,7 +4480,7 @@ static int open_cmdwin(void)
|
||||
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
|
||||
curwin->w_cursor.col = ccline.cmdpos;
|
||||
changed_line_abv_curs();
|
||||
invalidate_botline();
|
||||
invalidate_botline(curwin);
|
||||
if (ui_has(kUICmdline)) {
|
||||
ccline.redraw_state = kCmdRedrawNone;
|
||||
ui_call_cmdline_hide(ccline.level);
|
||||
|
Reference in New Issue
Block a user