aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2021-02-05 08:50:53 +0100
committerGitHub <noreply@github.com>2021-02-05 08:50:53 +0100
commitc95e797b83051683fa5ee727a256c5bf108b7040 (patch)
tree13ac5bf5ae16b91d1b281087fe83bdd2843226c6 /src
parent94cf7bba008ff0c36828565a408b7ef79203e069 (diff)
parent209fb35acda7d72aedab14952e46269f932afd1f (diff)
downloadrneovim-c95e797b83051683fa5ee727a256c5bf108b7040.tar.gz
rneovim-c95e797b83051683fa5ee727a256c5bf108b7040.tar.bz2
rneovim-c95e797b83051683fa5ee727a256c5bf108b7040.zip
Merge pull request #13878 from bfredl/incmark
inccommand: preserve extmarks when undoing preview substitution
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_cmds.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 9239eb5ca6..6d26c5f69c 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -3316,11 +3316,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout,
int save_b_changed = curbuf->b_changed;
bool preview = (State & CMDPREVIEW);
- // inccommand tests fail without this check
- if (!preview) {
- // Required for Undo to work for extmarks.
- u_save_cursor();
- }
+ bool did_save = false;
if (!global_busy) {
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)
? 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,
end.lnum-start.lnum, matchcols, replaced_bytes,
lnum-lnum_start, subcols, sublen-1, kExtmarkUndo);