mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 06:28:35 +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:
@@ -3922,7 +3922,7 @@ static void nv_gotofile(cmdarg_T *cap)
|
||||
buf_hide(curbuf) ? ECMD_HIDE : 0, curwin) == OK
|
||||
&& cap->nchar == 'F' && lnum >= 0) {
|
||||
curwin->w_cursor.lnum = lnum;
|
||||
check_cursor_lnum();
|
||||
check_cursor_lnum(curwin);
|
||||
beginline(BL_SOL | BL_FIX);
|
||||
}
|
||||
xfree(ptr);
|
||||
@@ -4771,7 +4771,7 @@ static void n_swapchar(cmdarg_T *cap)
|
||||
if (u_savesub(curwin->w_cursor.lnum) == false) {
|
||||
break;
|
||||
}
|
||||
u_clearline();
|
||||
u_clearline(curbuf);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
@@ -4782,7 +4782,7 @@ static void n_swapchar(cmdarg_T *cap)
|
||||
check_cursor();
|
||||
curwin->w_set_curswant = true;
|
||||
if (did_change) {
|
||||
changed_lines(startpos.lnum, startpos.col, curwin->w_cursor.lnum + 1,
|
||||
changed_lines(curbuf, startpos.lnum, startpos.col, curwin->w_cursor.lnum + 1,
|
||||
0L, true);
|
||||
curbuf->b_op_start = startpos;
|
||||
curbuf->b_op_end = curwin->w_cursor;
|
||||
@@ -5363,7 +5363,7 @@ static void nv_gi_cmd(cmdarg_T *cap)
|
||||
{
|
||||
if (curbuf->b_last_insert.mark.lnum != 0) {
|
||||
curwin->w_cursor = curbuf->b_last_insert.mark;
|
||||
check_cursor_lnum();
|
||||
check_cursor_lnum(curwin);
|
||||
int i = (int)strlen(get_cursor_line_ptr());
|
||||
if (curwin->w_cursor.col > (colnr_T)i) {
|
||||
if (virtual_active()) {
|
||||
|
Reference in New Issue
Block a user