mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 14:38:32 +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:
@@ -743,8 +743,7 @@ void deleteFold(win_T *const wp, const linenr_T start, const linenr_T end, const
|
||||
}
|
||||
|
||||
if (last_lnum > 0) {
|
||||
// TODO(teto): pass the buffer
|
||||
changed_lines(first_lnum, (colnr_T)0, last_lnum, 0L, false);
|
||||
changed_lines(wp->w_buffer, first_lnum, (colnr_T)0, last_lnum, 0L, false);
|
||||
|
||||
// send one nvim_buf_lines_event at the end
|
||||
// last_lnum is the line *after* the last line of the outermost fold
|
||||
@@ -1580,8 +1579,7 @@ static void foldCreateMarkers(win_T *wp, pos_T start, pos_T end)
|
||||
|
||||
// Update both changes here, to avoid all folds after the start are
|
||||
// changed when the start marker is inserted and the end isn't.
|
||||
// TODO(teto): pass the buffer
|
||||
changed_lines(start.lnum, (colnr_T)0, end.lnum, 0L, false);
|
||||
changed_lines(buf, start.lnum, (colnr_T)0, end.lnum, 0L, false);
|
||||
|
||||
// Note: foldAddMarker() may not actually change start and/or end if
|
||||
// u_save() is unable to save the buffer line, but we send the
|
||||
|
Reference in New Issue
Block a user