From 42caeccce6e50fa3b8b25fe3076ac2fbd555b152 Mon Sep 17 00:00:00 2001 From: raichoo Date: Sat, 11 Mar 2017 10:27:15 +0100 Subject: vim-patch:7.4.2322 Problem: Access memory beyond the end of the line. (Dominique Pelle) Solution: Adjust the cursor column. https://github.com/vim/vim/commit/bc54f3f3fed4dc3556df8c46cee6739d211b0eb2 --- src/nvim/move.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/move.c') diff --git a/src/nvim/move.c b/src/nvim/move.c index 4c1b8a8411..9ba515f209 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -1877,7 +1877,7 @@ int onepage(int dir, long count) } } foldAdjustCursor(); - cursor_correct(); + check_cursor_col(); if (retval == OK) beginline(BL_SOL | BL_FIX); curwin->w_valid &= ~(VALID_WCOL|VALID_WROW|VALID_VIRTCOL); -- cgit From 2ad25c04663da7d08da94db84dc6ded7df11ea87 Mon Sep 17 00:00:00 2001 From: raichoo Date: Sat, 11 Mar 2017 14:41:34 +0100 Subject: linter: make changes pass the linter --- src/nvim/move.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/nvim/move.c') diff --git a/src/nvim/move.c b/src/nvim/move.c index 9ba515f209..4c3f82bc16 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -1878,8 +1878,9 @@ int onepage(int dir, long count) } foldAdjustCursor(); check_cursor_col(); - if (retval == OK) + if (retval == OK) { beginline(BL_SOL | BL_FIX); + } curwin->w_valid &= ~(VALID_WCOL|VALID_WROW|VALID_VIRTCOL); /* -- cgit From 7418adc14375161b504e78c77c5c4e532016902c Mon Sep 17 00:00:00 2001 From: lonerover Date: Tue, 21 Mar 2017 21:36:31 +0800 Subject: move.c: add cursor adjustment for scrolloff (#6319) --- src/nvim/move.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/move.c') diff --git a/src/nvim/move.c b/src/nvim/move.c index 4c3f82bc16..4feabf624b 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -1877,6 +1877,7 @@ int onepage(int dir, long count) } } foldAdjustCursor(); + cursor_correct(); check_cursor_col(); if (retval == OK) { beginline(BL_SOL | BL_FIX); -- cgit From c2f3e361c52ec4e7149ea1d8c6a1202e0873da8e Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 19 Apr 2017 19:11:50 +0300 Subject: *: Add comment to all C files --- src/nvim/move.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/nvim/move.c') diff --git a/src/nvim/move.c b/src/nvim/move.c index 4feabf624b..d5be4cb8c3 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -1,3 +1,6 @@ +// This is an open source non-commercial project. Dear PVS-Studio, please check +// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com + /* * move.c: Functions for moving the cursor and scrolling text. * -- cgit From ad07e9c7fcabeb991f0849c9e11b5b225cf470fd Mon Sep 17 00:00:00 2001 From: ckelsel Date: Sun, 23 Jul 2017 10:12:05 +0800 Subject: vim-patch:8.0.0069 Problem: Compiler warning for self-comparison. Solution: Define ONE_WINDOW and add vim/vim#ifdef. https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660 --- src/nvim/move.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/move.c') diff --git a/src/nvim/move.c b/src/nvim/move.c index d5be4cb8c3..81d46a7f17 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -1763,7 +1763,7 @@ int onepage(int dir, long count) loff.fill = 0; if (dir == FORWARD) { - if (firstwin == lastwin && p_window > 0 && p_window < Rows - 1) { + if (ONE_WINDOW && p_window > 0 && p_window < Rows - 1) { /* Vi compatible scrolling */ if (p_window <= 2) ++curwin->w_topline; @@ -1797,7 +1797,7 @@ int onepage(int dir, long count) max_topfill(); continue; } - if (firstwin == lastwin && p_window > 0 && p_window < Rows - 1) { + if (ONE_WINDOW && p_window > 0 && p_window < Rows - 1) { /* Vi compatible scrolling (sort of) */ if (p_window <= 2) --curwin->w_topline; -- cgit From 8dddf5590796994254fb31b4cbe1736ec3faf9f6 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Wed, 19 Jul 2017 22:48:05 +0800 Subject: vim-patch:8.0.0044 Problem: In diff mode the cursor may end up below the last line, resulting in an ml_get error. Solution: Check the line to be valid. https://github.com/vim/vim/commit/025e3e0bafbc85cc4e365145af711edf99d0a90d --- src/nvim/move.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/nvim/move.c') diff --git a/src/nvim/move.c b/src/nvim/move.c index 81d46a7f17..4d646f5a4b 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -2147,14 +2147,12 @@ void do_check_cursorbind(void) curbuf = curwin->w_buffer; /* skip original window and windows with 'noscrollbind' */ if (curwin != old_curwin && curwin->w_p_crb) { - if (curwin->w_p_diff) - curwin->w_cursor.lnum - = diff_get_corresponding_line(old_curbuf, - line, - curbuf, - curwin->w_cursor.lnum); - else + if (curwin->w_p_diff) { + curwin->w_cursor.lnum = + diff_get_corresponding_line(old_curbuf, line); + } else { curwin->w_cursor.lnum = line; + } curwin->w_cursor.col = col; curwin->w_cursor.coladd = coladd; curwin->w_curswant = curswant; -- cgit From 82795c2c3a429b2725af882cad4317bed8f1b741 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Wed, 6 Sep 2017 01:04:57 +0800 Subject: vim-patch: 8.0.0{181,182,188} (#7152) vim-patch:8.0.0181 Problem: When 'cursorbind' and 'cursorcolumn' are both on, the column highlignt in non-current windows is wrong. Solution: Add validate_cursor(). (Masanori Misono, closes vim/vim#1372) https://github.com/vim/vim/commit/519d7785f4437762c07b2e04217f83a069a8c663 vim-patch:8.0.0182 Problem: When 'cursorbind' and 'cursorline' are set, but 'cursorcolumn' is not, then the cursor line highlighting is not updated. (Hirohito Higashi) Solution: Call redraw_later() with NOT_VALID. https://github.com/vim/vim/commit/e47683a0913f102b6ae08c8848d5aa675d99b188 vim-patch:8.0.0188 Problem: Using NOT_VALID for redraw_later() to update the cursor line/column highlighting is not efficient. Solution: Call validate_cursor() when 'cul' or 'cuc' is set. https://github.com/vim/vim/commit/9506cad7a1a6e52a613f356de969cbd980815777 --- src/nvim/move.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/nvim/move.c') diff --git a/src/nvim/move.c b/src/nvim/move.c index 4d646f5a4b..9693132846 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -2164,16 +2164,21 @@ void do_check_cursorbind(void) int restart_edit_save = restart_edit; restart_edit = true; check_cursor(); + if (curwin->w_p_cul || curwin->w_p_cuc) { + validate_cursor(); + } restart_edit = restart_edit_save; } - /* Correct cursor for multi-byte character. */ - if (has_mbyte) + // Correct cursor for multi-byte character. + if (has_mbyte) { mb_adjust_cursor(); + } redraw_later(VALID); - /* Only scroll when 'scrollbind' hasn't done this. */ - if (!curwin->w_p_scb) + // Only scroll when 'scrollbind' hasn't done this. + if (!curwin->w_p_scb) { update_topline(); + } curwin->w_redr_status = true; } } -- cgit From fe2546c81a8a7c0be5bbf0737d1169f6cd49bba0 Mon Sep 17 00:00:00 2001 From: Peter Kalauskas Date: Sun, 19 Nov 2017 12:19:09 -0800 Subject: move.c: remove unreachable break statement n > 0 verified by while condition, (--n < 0) always false --- src/nvim/move.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/nvim/move.c') diff --git a/src/nvim/move.c b/src/nvim/move.c index 9693132846..2debd90337 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -1989,8 +1989,7 @@ void halfpage(bool flag, linenr_T Prenum) while (n > 0 && curwin->w_botline <= curbuf->b_ml.ml_line_count) { if (curwin->w_topfill > 0) { i = 1; - if (--n < 0 && scrolled > 0) - break; + n--; --curwin->w_topfill; } else { i = plines_nofill(curwin->w_topline); @@ -2067,8 +2066,7 @@ void halfpage(bool flag, linenr_T Prenum) while (n > 0 && curwin->w_topline > 1) { if (curwin->w_topfill < diff_check_fill(curwin, curwin->w_topline)) { i = 1; - if (--n < 0 && scrolled > 0) - break; + n--; ++curwin->w_topfill; } else { i = plines_nofill(curwin->w_topline - 1); -- cgit