patch 9.1.0869: Problem: curswant not set on gm in folded line
Commit:
https://github.com/vim/vim/commit/9848face747ba91282d34a96dcb966bcb410bf2b
Author: Christian Brabandt <[email protected]>
Date: Sun Nov 17 16:18:00 2024 +0100
patch 9.1.0869: Problem: curswant not set on gm in folded line
Problem: curswant not set on gm in folded line
(citizenmatt)
Solution: in a folded line, call update_curswant_force()
fixes: #11596
closes: #11994
closes: #15398
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/src/normal.c b/src/normal.c
index 9e617d926..87e2cd475 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -5785,6 +5785,14 @@ nv_g_home_m_cmd(cmdarg_T *cap)
curwin->w_valid &= ~VALID_WCOL;
}
curwin->w_set_curswant = TRUE;
+#ifdef FEAT_FOLDING
+ if (hasAnyFolding(curwin))
+ {
+ validate_cheight();
+ if (curwin->w_cline_folded)
+ update_curswant_force();
+ }
+#endif
adjust_skipcol();
}
diff --git a/src/testdir/test_curswant.vim b/src/testdir/test_curswant.vim
index 7637850de..c67cca5f7 100644
--- a/src/testdir/test_curswant.vim
+++ b/src/testdir/test_curswant.vim
@@ -1,4 +1,7 @@
-" Tests for curswant not changing when setting an option
+" Tests for not changing curswant
+
+source check.vim
+source term_util.vim
func Test_curswant()
new
@@ -19,7 +22,50 @@ func Test_curswant()
let &ttimeoutlen=&ttimeoutlen
call assert_equal(7, winsaveview().curswant)
- enew!
+ bw!
+endfunc
+
+func Test_normal_gm()
+ CheckRunVimInTerminal
+ let lines =<< trim END
+ call setline(1, repeat([" abcd efgh ij"], 10))
+ call cursor(1, 1)
+ END
+ call writefile(lines, 'XtestCurswant', 'D')
+ let buf = RunVimInTerminal('-S XtestCurswant', #{rows: 10})
+ if has("folding")
+ call term_sendkeys(buf, "jVjzf")
+ " gm
+ call term_sendkeys(buf, "gmk")
+ call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
+ call WaitFor({-> term_getline(buf, 10) =~ '^18\s\+'})
+ " g0
+ call term_sendkeys(buf, "jg0k")
+ call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
+ call WaitFor({-> term_getline(buf, 10) =~ '^1\s\+'})
+ " g^
+ call term_sendkeys(buf, "jg^k")
+ call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
+ call WaitFor({-> term_getline(buf, 10) =~ '^3\s\+'})
+ endif
+ call term_sendkeys(buf, ":call cursor(10, 1)\<cr>")
+ " gm
+ call term_sendkeys(buf, "gmk")
+ call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
+ call term_wait(buf)
+ call WaitFor({-> term_getline(buf, 10) =~ '^18\s\+'})
+ " g0
+ call term_sendkeys(buf, "g0k")
+ call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
+ call WaitFor({-> term_getline(buf, 10) =~ '^1\s\+'})
+ " g^
+ call term_sendkeys(buf, "g^k")
+ call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
+ call WaitFor({-> term_getline(buf, 10) =~ '^3\s\+'})
+ " clean up
+ call StopVimInTerminal(buf)
+ wincmd p
+ wincmd c
endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index b4eb42905..3ccae20d7 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 869,
/**/
868,
/**/
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1tChDw-002S1L-37%40256bit.org.