Skip to content

Commit 5390144

Browse files
committed
patch 8.1.0212: preferred cursor column not set in interfaces
Problem: Preferred cursor column not set in interfaces. Solution: Set w_set_curswant when setting the cursor. (David Hotham, closes #3060)
1 parent 00136dc commit 5390144

13 files changed

Lines changed: 93 additions & 1 deletion

src/if_lua.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,7 @@ luaV_window_newindex (lua_State *L)
13771377
luaV_checksandbox(L);
13781378
#endif
13791379
w->w_cursor.col = v - 1;
1380+
w->w_set_curswant = TRUE;
13801381
update_screen(VALID);
13811382
}
13821383
else if (strncmp(s, "width", 5) == 0)

src/if_mzsch.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,6 +2132,7 @@ set_cursor(void *data, int argc, Scheme_Object **argv)
21322132

21332133
win->win->w_cursor.lnum = lnum;
21342134
win->win->w_cursor.col = col;
2135+
win->win->w_set_curswant = TRUE;
21352136
update_screen(VALID);
21362137

21372138
raise_if_error();

src/if_perl.xs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,6 +1691,7 @@ Cursor(win, ...)
16911691
col = (int) SvIV(ST(2));
16921692
win->w_cursor.lnum = lnum;
16931693
win->w_cursor.col = col;
1694+
win->w_set_curswant = TRUE;
16941695
check_cursor(); /* put cursor on an existing line */
16951696
update_screen(NOT_VALID);
16961697
}

src/if_py_both.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3985,6 +3985,7 @@ WindowSetattr(WindowObject *self, char *name, PyObject *valObject)
39853985

39863986
self->win->w_cursor.lnum = lnum;
39873987
self->win->w_cursor.col = col;
3988+
self->win->w_set_curswant = TRUE;
39883989
#ifdef FEAT_VIRTUALEDIT
39893990
self->win->w_cursor.coladd = 0;
39903991
#endif

src/if_ruby.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,6 +1517,7 @@ static VALUE window_set_cursor(VALUE self, VALUE pos)
15171517
col = RARRAY_PTR(pos)[1];
15181518
win->w_cursor.lnum = NUM2LONG(lnum);
15191519
win->w_cursor.col = NUM2UINT(col);
1520+
win->w_set_curswant = TRUE;
15201521
check_cursor(); /* put cursor on an existing line */
15211522
update_screen(NOT_VALID);
15221523
return Qnil;

src/if_tcl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,7 @@ winselfcmd(
10911091
/* TODO: should check column */
10921092
win->w_cursor.lnum = val1;
10931093
win->w_cursor.col = col2vim(val2);
1094+
win->w_set_curswant = TRUE;
10941095
flags |= FL_UPDATE_SCREEN;
10951096
break;
10961097

src/testdir/test_lua.vim

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,3 +555,20 @@ func Test_luafile_error()
555555
call delete('Xlua_file')
556556
bwipe!
557557
endfunc
558+
559+
func Test_set_cursor()
560+
" Check that setting the cursor position works.
561+
new
562+
call setline(1, ['first line', 'second line'])
563+
normal gg
564+
lua << EOF
565+
w = vim.window()
566+
w.line = 1
567+
w.col = 5
568+
EOF
569+
call assert_equal([1, 5], [line('.'), col('.')])
570+
571+
" Check that movement after setting cursor position keeps current column.
572+
normal j
573+
call assert_equal([2, 5], [line('.'), col('.')])
574+
endfunc

src/testdir/test_perl.vim

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,3 +258,16 @@ func Test_000_SvREFCNT()
258258
--perl
259259
%bw!
260260
endfunc
261+
262+
func Test_set_cursor()
263+
" Check that setting the cursor position works.
264+
new
265+
call setline(1, ['first line', 'second line'])
266+
normal gg
267+
perldo $curwin->Cursor(1, 5)
268+
call assert_equal([1, 6], [line('.'), col('.')])
269+
270+
" Check that movement after setting cursor position keeps current column.
271+
normal j
272+
call assert_equal([2, 6], [line('.'), col('.')])
273+
endfunc

src/testdir/test_python2.vim

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,17 @@ func Test_pydo()
2222
bwipe!
2323
bwipe!
2424
endfunc
25+
26+
func Test_set_cursor()
27+
" Check that setting the cursor position works.
28+
py import vim
29+
new
30+
call setline(1, ['first line', 'second line'])
31+
normal gg
32+
pydo vim.current.window.cursor = (1, 5)
33+
call assert_equal([1, 6], [line('.'), col('.')])
34+
35+
" Check that movement after setting cursor position keeps current column.
36+
normal j
37+
call assert_equal([2, 6], [line('.'), col('.')])
38+
endfunc

src/testdir/test_python3.vim

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
" Test for python 2 commands.
1+
" Test for python 3 commands.
22
" TODO: move tests from test88.in here.
33

44
if !has('python3')
@@ -22,3 +22,17 @@ func Test_py3do()
2222
bwipe!
2323
bwipe!
2424
endfunc
25+
26+
func Test_set_cursor()
27+
" Check that setting the cursor position works.
28+
py3 import vim
29+
new
30+
call setline(1, ['first line', 'second line'])
31+
normal gg
32+
py3do vim.current.window.cursor = (1, 5)
33+
call assert_equal([1, 6], [line('.'), col('.')])
34+
35+
" Check that movement after setting cursor position keeps current column.
36+
normal j
37+
call assert_equal([2, 6], [line('.'), col('.')])
38+
endfunc

0 commit comments

Comments
 (0)