mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
inccommand: preserve extmarks when undoing preview substitution
This commit is contained in:
parent
94cf7bba00
commit
aa50369897
@ -3316,11 +3316,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout,
|
|||||||
int save_b_changed = curbuf->b_changed;
|
int save_b_changed = curbuf->b_changed;
|
||||||
bool preview = (State & CMDPREVIEW);
|
bool preview = (State & CMDPREVIEW);
|
||||||
|
|
||||||
// inccommand tests fail without this check
|
bool did_save = false;
|
||||||
if (!preview) {
|
|
||||||
// Required for Undo to work for extmarks.
|
|
||||||
u_save_cursor();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!global_busy) {
|
if (!global_busy) {
|
||||||
sub_nsubs = 0;
|
sub_nsubs = 0;
|
||||||
@ -3997,6 +3993,11 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout,
|
|||||||
int matchcols = end.col - ((end.lnum == start.lnum)
|
int matchcols = end.col - ((end.lnum == start.lnum)
|
||||||
? start.col : 0);
|
? start.col : 0);
|
||||||
int subcols = new_endcol - ((lnum == lnum_start) ? start_col : 0);
|
int subcols = new_endcol - ((lnum == lnum_start) ? start_col : 0);
|
||||||
|
if (!did_save) {
|
||||||
|
// Required for Undo to work for extmarks.
|
||||||
|
u_save_cursor();
|
||||||
|
did_save = true;
|
||||||
|
}
|
||||||
extmark_splice(curbuf, lnum_start-1, start_col,
|
extmark_splice(curbuf, lnum_start-1, start_col,
|
||||||
end.lnum-start.lnum, matchcols, replaced_bytes,
|
end.lnum-start.lnum, matchcols, replaced_bytes,
|
||||||
lnum-lnum_start, subcols, sublen-1, kExtmarkUndo);
|
lnum-lnum_start, subcols, sublen-1, kExtmarkUndo);
|
||||||
|
@ -504,11 +504,13 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
|||||||
feed ':%s/bcd/'
|
feed ':%s/bcd/'
|
||||||
check_events {
|
check_events {
|
||||||
{ "test1", "bytes", 1, 3, 0, 1, 1, 0, 3, 3, 0, 0, 0 };
|
{ "test1", "bytes", 1, 3, 0, 1, 1, 0, 3, 3, 0, 0, 0 };
|
||||||
|
{ "test1", "bytes", 1, 5, 0, 1, 1, 0, 0, 0, 0, 3, 3 };
|
||||||
}
|
}
|
||||||
|
|
||||||
feed 'a'
|
feed 'a'
|
||||||
check_events {
|
check_events {
|
||||||
{ "test1", "bytes", 1, 3, 0, 1, 1, 0, 3, 3, 0, 1, 1 };
|
{ "test1", "bytes", 1, 3, 0, 1, 1, 0, 3, 3, 0, 1, 1 };
|
||||||
|
{ "test1", "bytes", 1, 5, 0, 1, 1, 0, 1, 1, 0, 3, 3 };
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user