Skip to content

Commit 9848fac

Browse files
committed
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 <cb@256bit.org>
1 parent 8b94afc commit 9848fac

3 files changed

Lines changed: 58 additions & 2 deletions

File tree

src/normal.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5785,6 +5785,14 @@ nv_g_home_m_cmd(cmdarg_T *cap)
57855785
curwin->w_valid &= ~VALID_WCOL;
57865786
}
57875787
curwin->w_set_curswant = TRUE;
5788+
#ifdef FEAT_FOLDING
5789+
if (hasAnyFolding(curwin))
5790+
{
5791+
validate_cheight();
5792+
if (curwin->w_cline_folded)
5793+
update_curswant_force();
5794+
}
5795+
#endif
57885796
adjust_skipcol();
57895797
}
57905798

src/testdir/test_curswant.vim

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
" Tests for curswant not changing when setting an option
1+
" Tests for not changing curswant
2+
3+
source check.vim
4+
source term_util.vim
25

36
func Test_curswant()
47
new
@@ -19,7 +22,50 @@ func Test_curswant()
1922
let &ttimeoutlen=&ttimeoutlen
2023
call assert_equal(7, winsaveview().curswant)
2124

22-
enew!
25+
bw!
26+
endfunc
27+
28+
func Test_normal_gm()
29+
CheckRunVimInTerminal
30+
let lines =<< trim END
31+
call setline(1, repeat([" abcd\tefgh\tij"], 10))
32+
call cursor(1, 1)
33+
END
34+
call writefile(lines, 'XtestCurswant', 'D')
35+
let buf = RunVimInTerminal('-S XtestCurswant', #{rows: 10})
36+
if has("folding")
37+
call term_sendkeys(buf, "jVjzf")
38+
" gm
39+
call term_sendkeys(buf, "gmk")
40+
call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
41+
call WaitFor({-> term_getline(buf, 10) =~ '^18\s\+'})
42+
" g0
43+
call term_sendkeys(buf, "jg0k")
44+
call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
45+
call WaitFor({-> term_getline(buf, 10) =~ '^1\s\+'})
46+
" g^
47+
call term_sendkeys(buf, "jg^k")
48+
call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
49+
call WaitFor({-> term_getline(buf, 10) =~ '^3\s\+'})
50+
endif
51+
call term_sendkeys(buf, ":call cursor(10, 1)\<cr>")
52+
" gm
53+
call term_sendkeys(buf, "gmk")
54+
call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
55+
call term_wait(buf)
56+
call WaitFor({-> term_getline(buf, 10) =~ '^18\s\+'})
57+
" g0
58+
call term_sendkeys(buf, "g0k")
59+
call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
60+
call WaitFor({-> term_getline(buf, 10) =~ '^1\s\+'})
61+
" g^
62+
call term_sendkeys(buf, "g^k")
63+
call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
64+
call WaitFor({-> term_getline(buf, 10) =~ '^3\s\+'})
65+
" clean up
66+
call StopVimInTerminal(buf)
67+
wincmd p
68+
wincmd c
2369
endfunc
2470

2571
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
869,
707709
/**/
708710
868,
709711
/**/

0 commit comments

Comments
 (0)