From 179f0bca1890637f47e76c8acfd33040a6b7d515 Mon Sep 17 00:00:00 2001 From: Thomas Vigouroux Date: Fri, 18 Sep 2020 08:44:32 +0200 Subject: buf_updates: fix wrong updates on linewise change --- src/nvim/ops.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 1f55d2c315..92d026465f 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -1544,15 +1544,19 @@ 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; del_lines(oap->line_count - 1, TRUE); curwin->w_cursor.lnum = lnum; + + extmark_adjust(curbuf, curwin->w_cursor.lnum, + curwin->w_cursor.lnum + oap->line_count - 1, + MAXLNUM, 0, kExtmarkUndo); } if (u_save_cursor() == FAIL) return FAIL; @@ -1561,9 +1565,16 @@ int op_delete(oparg_T *oap) 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 */ + 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, 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 { -- cgit From b7fc7ac6a115ce88df3cbbf6c0ad1a89791dc47c Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sat, 19 Sep 2020 10:01:00 +0200 Subject: buffer updates: fix issues with "change" operator --- src/nvim/ops.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 92d026465f..36b1b662f7 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -1553,10 +1553,6 @@ int op_delete(oparg_T *oap) ++curwin->w_cursor.lnum; del_lines(oap->line_count - 1, TRUE); curwin->w_cursor.lnum = lnum; - - extmark_adjust(curbuf, curwin->w_cursor.lnum, - curwin->w_cursor.lnum + oap->line_count - 1, - MAXLNUM, 0, kExtmarkUndo); } if (u_save_cursor() == FAIL) return FAIL; @@ -1571,7 +1567,7 @@ int op_delete(oparg_T *oap) truncate_line(FALSE); // delete the rest of the line extmark_splice_cols(curbuf, - (int)curwin->w_cursor.lnum, curwin->w_cursor.col, + (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 -- cgit From 0ba2b955afb7b92e5c68b7dc8f4232ddb67b4b54 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sat, 19 Sep 2020 10:01:38 +0200 Subject: util: make __asan_* prototypes available for ENHANCED printf debuging --- src/nvim/log.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') 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 -- cgit From 2f2c73265fd63af2f60799767417043ed15bd42c Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sat, 19 Sep 2020 10:14:13 +0200 Subject: lint: is lint --- src/nvim/ops.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 36b1b662f7..6209dd6492 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -1560,19 +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 + } 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 + 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" */ + 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); -- cgit