diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2021-04-04 09:42:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-04 09:42:34 +0200 |
commit | ce976bf3559edca6d3a649c9053fab88959de6cf (patch) | |
tree | 4bcb56dae770723c0e7bce7ad97ce4ae574d64ee /src/nvim/ex_cmds.c | |
parent | 8e496b9dfd5b644f06536afea63e3088b9d83cf8 (diff) | |
parent | 7602c560508de35c9e211ecc732fda0ff3c06923 (diff) | |
download | rneovim-ce976bf3559edca6d3a649c9053fab88959de6cf.tar.gz rneovim-ce976bf3559edca6d3a649c9053fab88959de6cf.tar.bz2 rneovim-ce976bf3559edca6d3a649c9053fab88959de6cf.zip |
Merge pull request #14278 from chentau/extmark_retab
extmark: buffer update fixes for `noexpandtab` and `:retab`
Diffstat (limited to 'src/nvim/ex_cmds.c')
-rw-r--r-- | src/nvim/ex_cmds.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index d34282419a..b191e8cf67 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -790,7 +790,8 @@ void ex_retab(exarg_T *eap) /* len is actual number of white characters used */ len = num_spaces + num_tabs; old_len = (long)STRLEN(ptr); - new_line = xmalloc(old_len - col + start_col + len + 1); + long new_len = old_len - col + start_col + len + 1; + new_line = xmalloc(new_len); if (start_col > 0) memmove(new_line, ptr, (size_t)start_col); @@ -803,6 +804,8 @@ void ex_retab(exarg_T *eap) if (ml_replace(lnum, new_line, false) == OK) { // "new_line" may have been copied new_line = curbuf->b_ml.ml_line_ptr; + extmark_splice_cols(curbuf, lnum - 1, 0, (colnr_T)old_len, + (colnr_T)new_len - 1, kExtmarkUndo); } if (first_line == 0) { first_line = lnum; |