diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2020-09-19 11:02:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-19 11:02:32 +0200 |
commit | cea2417f30bf728cd818311b1988e0ce223011d8 (patch) | |
tree | 39b327ea24c97778ff57371d3c11fe4d056eb4da /src | |
parent | 569e75799d7015b15631c80cee1feec561f29df7 (diff) | |
parent | 2f2c73265fd63af2f60799767417043ed15bd42c (diff) | |
download | rneovim-cea2417f30bf728cd818311b1988e0ce223011d8.tar.gz rneovim-cea2417f30bf728cd818311b1988e0ce223011d8.tar.bz2 rneovim-cea2417f30bf728cd818311b1988e0ce223011d8.zip |
Merge pull request #12935 from vigoux/byte-change-lines
buf_updates: fix wrong updates on linewise change
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/log.h | 4 | ||||
-rw-r--r-- | src/nvim/ops.c | 29 |
2 files changed, 23 insertions, 10 deletions
diff --git a/src/nvim/log.h b/src/nvim/log.h index 17ff095473..a6a4c78707 100644 --- a/src/nvim/log.h +++ b/src/nvim/log.h @@ -68,6 +68,10 @@ # define LOG_CALLSTACK_TO_FILE(fp) log_callstack_to_file(fp, __func__, __LINE__) #endif +#if defined(__has_include) && __has_include("sanitizer/asan_interface.h") +# include "sanitizer/asan_interface.h" +#endif + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "log.h.generated.h" #endif diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 1f55d2c315..6209dd6492 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -1544,10 +1544,10 @@ int op_delete(oparg_T *oap) oap->line_count = 0; // no lines deleted } else if (oap->motion_type == kMTLineWise) { if (oap->op_type == OP_CHANGE) { - /* Delete the lines except the first one. Temporarily move the - * cursor to the next line. Save the current line number, if the - * last line is deleted it may be changed. - */ + // Delete the lines except the first one. Temporarily move the + // cursor to the next line. Save the current line number, if the + // last line is deleted it may be changed. + if (oap->line_count > 1) { lnum = curwin->w_cursor.lnum; ++curwin->w_cursor.lnum; @@ -1560,12 +1560,21 @@ int op_delete(oparg_T *oap) beginline(BL_WHITE); // cursor on first non-white did_ai = true; // delete the indent when ESC hit ai_col = curwin->w_cursor.col; - } else - beginline(0); /* cursor in column 0 */ - truncate_line(FALSE); /* delete the rest of the line */ - /* leave cursor past last char in line */ - if (oap->line_count > 1) - u_clearline(); /* "U" command not possible after "2cc" */ + } else { + beginline(0); // cursor in column 0 + } + + int old_len = (int)STRLEN(ml_get(curwin->w_cursor.lnum)); + truncate_line(false); // delete the rest of the line + + extmark_splice_cols(curbuf, + (int)curwin->w_cursor.lnum-1, curwin->w_cursor.col, + old_len - curwin->w_cursor.col, 0, kExtmarkUndo); + + // leave cursor past last char in line + if (oap->line_count > 1) { + u_clearline(); // "U" command not possible after "2cc" + } } else { del_lines(oap->line_count, TRUE); beginline(BL_WHITE | BL_FIX); |