aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/edit.c
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2024-07-26 00:32:54 +0200
committerGitHub <noreply@github.com>2024-07-26 06:32:54 +0800
commitdd61be59af5bb97f2f28ec0040ab1597795a48c5 (patch)
treeb644df4918710ec4760b8ca7362c2dd5ffc27546 /src/nvim/edit.c
parent807eb4434c890118e632ec57e396fd151c441714 (diff)
downloadrneovim-dd61be59af5bb97f2f28ec0040ab1597795a48c5.tar.gz
rneovim-dd61be59af5bb97f2f28ec0040ab1597795a48c5.tar.bz2
rneovim-dd61be59af5bb97f2f28ec0040ab1597795a48c5.zip
vim-patch:9.1.0617: Cursor moves beyond first line of folded end of buffer (#29859)
Problem: Cursor moves beyond start of a folded range at the end of a buffer. Solution: Move cursor to start of fold when going beyond end of buffer. Check that cursor moved to detect FAIL in outer cursor function. (Luuk van Baal) https://github.com/vim/vim/commit/dc373d456b5919ed2b8f83e8642c115f646ca93d
Diffstat (limited to 'src/nvim/edit.c')
-rw-r--r--src/nvim/edit.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 694a656323..5c88cb59e1 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -2650,7 +2650,6 @@ void cursor_down_inner(win_T *wp, int n)
// count each sequence of folded lines as one logical line
while (n--) {
- // Move to last line of fold, will fail if it's the end-of-file.
if (hasFoldingWin(wp, lnum, NULL, &last, true, NULL)) {
lnum = last + 1;
} else {
@@ -2673,8 +2672,10 @@ void cursor_down_inner(win_T *wp, int n)
/// @param upd_topline When true: update topline
int cursor_down(int n, bool upd_topline)
{
- // This fails if the cursor is already in the last line.
- if (n > 0 && curwin->w_cursor.lnum >= curwin->w_buffer->b_ml.ml_line_count) {
+ linenr_T lnum = curwin->w_cursor.lnum;
+ // This fails if the cursor is already in the last (folded) line.
+ hasFoldingWin(curwin, lnum, NULL, &lnum, true, NULL);
+ if (n > 0 && lnum >= curwin->w_buffer->b_ml.ml_line_count) {
return FAIL;
}
cursor_down_inner(curwin, n);