From: Sergey Vlasov Date: Sat, 18 Jul 2026 13:11:06 +0000 (+0000) Subject: patch 9.2.0791: wincol() counts from right side for 'rightleft' X-Git-Tag: v9.2.0791^0 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=95a1932e87bbb9c90842a4341d5c6f0efa99fe7a;p=thirdparty%2Fvim.git patch 9.2.0791: wincol() counts from right side for 'rightleft' Problem: wincol() counts cells from right side of the window if 'rightleft' is enabled. Solution: Fix wincol() to count from left side of the window as documented (Sergey Vlasov). closes: #20763 Signed-off-by: Sergey Vlasov Signed-off-by: Christian Brabandt --- diff --git a/src/evalwindow.c b/src/evalwindow.c index c93979e08c..23cd92b677 100644 --- a/src/evalwindow.c +++ b/src/evalwindow.c @@ -1126,7 +1126,12 @@ f_winbufnr(typval_T *argvars, typval_T *rettv) f_wincol(typval_T *argvars UNUSED, typval_T *rettv) { validate_cursor(); - rettv->vval.v_number = curwin->w_wcol + 1; + int col = curwin->w_wcol + 1; +# ifdef FEAT_RIGHTLEFT + if (curwin->w_p_rl) + col = curwin->w_width - col + 1; +# endif + rettv->vval.v_number = col; } /* diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim index d2e5f6e21a..9882183429 100644 --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -1,6 +1,7 @@ " Tests for various functions. source util/screendump.vim +source util/view_util.vim import './util/vim9.vim' as v9 " Must be done first, since the alternate buffer must be unset. @@ -4705,4 +4706,40 @@ func Test_vim9_def_defer_fc_sandbox() delfunction g:BadDefer endfunc +" Test wincol() counts in screen cells from left side of the window +func Test_wincol() + enew! + set ff=unix mouse=a + + let win_width = 30 + call NewWindow(20, win_width) + + call setline(1, "the quick brown fox jump") + + norm! 0 + call assert_equal([1, 1], [winline(), wincol()]) + + call test_setmouse(1, 10) + call feedkeys("\\", "xt") + call assert_equal([1, 10], [winline(), wincol()]) + + if has('rightleft') + norm! 0 + call assert_equal([1, 1], [winline(), wincol()]) + + set rightleft + " cursor is still at column 1, but in screen cells it is at the distance of window width: + call assert_equal([1, win_width], [winline(), wincol()]) + + " test_setmouse() works in screen coordinates, which is not affected by 'rightleft': + call test_setmouse(1, 10) + call feedkeys("\\", "xt") + call assert_equal([1, 10], [winline(), wincol()]) + set rightleft& + endif + + set ff& mouse& + bw! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index f9abe4fa15..77d596c04e 100644 --- a/src/version.c +++ b/src/version.c @@ -759,6 +759,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 791, /**/ 790, /**/