mirror of
https://github.com/neovim/neovim.git
synced 2024-12-29 14:41:06 -07:00
buffer_updates: autoload episode III: revenge of the trees
This commit is contained in:
parent
5ad32885d4
commit
c7a65fe6a1
@ -580,6 +580,10 @@ int u_savecommon(linenr_T top, linenr_T bot, linenr_T newbot, int reload)
|
||||
uep->ue_array = NULL;
|
||||
uep->ue_next = curbuf->b_u_newhead->uh_entry;
|
||||
curbuf->b_u_newhead->uh_entry = uep;
|
||||
if (reload) {
|
||||
// buffer was reloaded, notify text change subscribers
|
||||
curbuf->b_u_newhead->uh_flags |= UH_RELOAD;
|
||||
}
|
||||
curbuf->b_u_synced = false;
|
||||
undo_undoes = false;
|
||||
|
||||
@ -2157,8 +2161,9 @@ static void u_undoredo(int undo, bool do_buf_event)
|
||||
u_check(FALSE);
|
||||
#endif
|
||||
old_flags = curhead->uh_flags;
|
||||
new_flags = (curbuf->b_changed ? UH_CHANGED : 0) +
|
||||
((curbuf->b_ml.ml_flags & ML_EMPTY) ? UH_EMPTYBUF : 0);
|
||||
new_flags = (curbuf->b_changed ? UH_CHANGED : 0)
|
||||
| ((curbuf->b_ml.ml_flags & ML_EMPTY) ? UH_EMPTYBUF : 0)
|
||||
| (old_flags & UH_RELOAD);
|
||||
setpcmark();
|
||||
|
||||
/*
|
||||
@ -2299,6 +2304,11 @@ static void u_undoredo(int undo, bool do_buf_event)
|
||||
extmark_apply_undo(undo_info, undo);
|
||||
}
|
||||
}
|
||||
if (curhead->uh_flags & UH_RELOAD) {
|
||||
// TODO(bfredl): this is a bit crude. When 'undoreload' is used we
|
||||
// should have all info to send a buffer-reloaing on_lines/on_bytes event
|
||||
buf_updates_unload(curbuf, true);
|
||||
}
|
||||
// finish Adjusting extmarks
|
||||
|
||||
|
||||
|
@ -69,9 +69,10 @@ struct u_header {
|
||||
#endif
|
||||
};
|
||||
|
||||
/* values for uh_flags */
|
||||
#define UH_CHANGED 0x01 /* b_changed flag before undo/after redo */
|
||||
#define UH_EMPTYBUF 0x02 /* buffer was empty */
|
||||
// values for uh_flags
|
||||
#define UH_CHANGED 0x01 // b_changed flag before undo/after redo
|
||||
#define UH_EMPTYBUF 0x02 // buffer was empty
|
||||
#define UH_RELOAD 0x04 // buffer was reloaded
|
||||
|
||||
/// Structure passed around between undofile functions.
|
||||
typedef struct {
|
||||
|
@ -635,6 +635,27 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
||||
}
|
||||
|
||||
eq({'new line 1 new line 2', 'new line 3'}, meths.buf_get_lines(0, 0, -1, true))
|
||||
|
||||
-- check we can undo and redo a reload event.
|
||||
feed 'u'
|
||||
check_events {
|
||||
{ "test1", "bytes", 1, 8, 0, 10, 10, 0, 1, 1, 1, 0, 1 };
|
||||
}
|
||||
|
||||
feed 'u'
|
||||
check_events {
|
||||
{ "test1", "reload", 1 };
|
||||
}
|
||||
|
||||
feed '<c-r>'
|
||||
check_events {
|
||||
{ "test1", "reload", 1 };
|
||||
}
|
||||
|
||||
feed '<c-r>'
|
||||
check_events {
|
||||
{ "test1", "bytes", 1, 14, 0, 10, 10, 1, 0, 1, 0, 1, 1 };
|
||||
}
|
||||
end)
|
||||
|
||||
teardown(function()
|
||||
|
Loading…
Reference in New Issue
Block a user