]> granicus.if.org Git - vim/commitdiff
patch 8.1.0212: preferred cursor column not set in interfaces v8.1.0212
authorBram Moolenaar <Bram@vim.org>
Wed, 25 Jul 2018 20:02:36 +0000 (22:02 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 25 Jul 2018 20:02:36 +0000 (22:02 +0200)
Problem:    Preferred cursor column not set in interfaces.
Solution:   Set w_set_curswant when setting the cursor. (David Hotham,
            closes #3060)

13 files changed:
src/if_lua.c
src/if_mzsch.c
src/if_perl.xs
src/if_py_both.h
src/if_ruby.c
src/if_tcl.c
src/testdir/test_lua.vim
src/testdir/test_perl.vim
src/testdir/test_python2.vim
src/testdir/test_python3.vim
src/testdir/test_ruby.vim
src/testdir/test_tcl.vim
src/version.c

index c0d809adc9268dacf5817633936c2fe86e256f46..7602c80de48a62a514c8ef5213bf4750ead24a39 100644 (file)
@@ -1377,6 +1377,7 @@ luaV_window_newindex (lua_State *L)
        luaV_checksandbox(L);
 #endif
        w->w_cursor.col = v - 1;
+       w->w_set_curswant = TRUE;
        update_screen(VALID);
     }
     else if (strncmp(s, "width", 5) == 0)
index 54474bd807a3cecb90deec125944772dc170266f..23b67a99b22f6b9f09dec6fba0c21c74341923d7 100644 (file)
@@ -2132,6 +2132,7 @@ set_cursor(void *data, int argc, Scheme_Object **argv)
 
     win->win->w_cursor.lnum = lnum;
     win->win->w_cursor.col = col;
+    win->win->w_set_curswant = TRUE;
     update_screen(VALID);
 
     raise_if_error();
index 55a24c6ac7623b68cd8191c1a916367612a3f1c1..bc15efa944b6546b803b4ffd2622f703981b3112 100644 (file)
@@ -1691,6 +1691,7 @@ Cursor(win, ...)
       col = (int) SvIV(ST(2));
       win->w_cursor.lnum = lnum;
       win->w_cursor.col = col;
+      win->w_set_curswant = TRUE;
       check_cursor();              /* put cursor on an existing line */
       update_screen(NOT_VALID);
     }
index 58db254dcc3c019e4ae1f702a5a91d8038c4be4d..459bc50cddc5cffe58b8b619db2508b1a3300043 100644 (file)
@@ -3985,6 +3985,7 @@ WindowSetattr(WindowObject *self, char *name, PyObject *valObject)
 
        self->win->w_cursor.lnum = lnum;
        self->win->w_cursor.col = col;
+       self->win->w_set_curswant = TRUE;
 #ifdef FEAT_VIRTUALEDIT
        self->win->w_cursor.coladd = 0;
 #endif
index d67801dfa53e7cf1c2e8f9b8bb891b85947622a0..4b9af318d2acbc65d23557affc54ad99b6b635e4 100644 (file)
@@ -1517,6 +1517,7 @@ static VALUE window_set_cursor(VALUE self, VALUE pos)
     col = RARRAY_PTR(pos)[1];
     win->w_cursor.lnum = NUM2LONG(lnum);
     win->w_cursor.col = NUM2UINT(col);
+    win->w_set_curswant = TRUE;
     check_cursor();                /* put cursor on an existing line */
     update_screen(NOT_VALID);
     return Qnil;
index 9ecabf84c5e58922f7876b2193bc7a857f1c7fa3..228936554c41f5272d8e024ee7d52581b4f95cf4 100644 (file)
@@ -1091,6 +1091,7 @@ winselfcmd(
            /* TODO: should check column */
            win->w_cursor.lnum = val1;
            win->w_cursor.col = col2vim(val2);
+           win->w_set_curswant = TRUE;
            flags |= FL_UPDATE_SCREEN;
            break;
 
index 22807920346be775ba49ca4c8e26f127a8323eec..e021a2f447126955a20eb2c64be8a8a7dadb98e0 100644 (file)
@@ -555,3 +555,20 @@ func Test_luafile_error()
   call delete('Xlua_file')
   bwipe!
 endfunc
+
+func Test_set_cursor()
+  " Check that setting the cursor position works.
+  new
+  call setline(1, ['first line', 'second line'])
+  normal gg
+  lua << EOF
+w = vim.window()
+w.line = 1
+w.col = 5
+EOF
+  call assert_equal([1, 5], [line('.'), col('.')])
+
+  " Check that movement after setting cursor position keeps current column.
+  normal j
+  call assert_equal([2, 5], [line('.'), col('.')])
+endfunc
index 0528814b422546469624f50521ab4123bdbf29a6..661c65cdc8f6f452e3a6b60b68bbc6a96eaee4bd 100644 (file)
@@ -258,3 +258,16 @@ func Test_000_SvREFCNT()
 --perl
   %bw!
 endfunc
+
+func Test_set_cursor()
+  " Check that setting the cursor position works.
+  new
+  call setline(1, ['first line', 'second line'])
+  normal gg
+  perldo $curwin->Cursor(1, 5)
+  call assert_equal([1, 6], [line('.'), col('.')])
+
+  " Check that movement after setting cursor position keeps current column.
+  normal j
+  call assert_equal([2, 6], [line('.'), col('.')])
+endfunc
index fb98c1eda72f4a8dbbae4d03a83d424d7d4c5264..c438ba04158d20521bbd00443043a98c15052832 100644 (file)
@@ -22,3 +22,17 @@ func Test_pydo()
   bwipe!
   bwipe!
 endfunc
+
+func Test_set_cursor()
+  " Check that setting the cursor position works.
+  py import vim
+  new
+  call setline(1, ['first line', 'second line'])
+  normal gg
+  pydo vim.current.window.cursor = (1, 5)
+  call assert_equal([1, 6], [line('.'), col('.')])
+
+  " Check that movement after setting cursor position keeps current column.
+  normal j
+  call assert_equal([2, 6], [line('.'), col('.')])
+endfunc
index bb241dacb16ce558a9982633370c6b80198dceac..69ad8021316172d0cd9509877344bf04553be792 100644 (file)
@@ -1,4 +1,4 @@
-" Test for python 2 commands.
+" Test for python 3 commands.
 " TODO: move tests from test88.in here.
 
 if !has('python3')
@@ -22,3 +22,17 @@ func Test_py3do()
   bwipe!
   bwipe!
 endfunc
+
+func Test_set_cursor()
+  " Check that setting the cursor position works.
+  py3 import vim
+  new
+  call setline(1, ['first line', 'second line'])
+  normal gg
+  py3do vim.current.window.cursor = (1, 5)
+  call assert_equal([1, 6], [line('.'), col('.')])
+
+  " Check that movement after setting cursor position keeps current column.
+  normal j
+  call assert_equal([2, 6], [line('.'), col('.')])
+endfunc
index 0017f73aefae8a191e38c84fc262e20a443cf880..ae27b39cd31453657877927d6dc924b8da1a9dd8 100644 (file)
@@ -57,3 +57,16 @@ func Test_rubyfile()
   call assert_fails('rubyfile ' . tempfile)
   call delete(tempfile)
 endfunc
+
+func Test_set_cursor()
+  " Check that setting the cursor position works.
+  new
+  call setline(1, ['first line', 'second line'])
+  normal gg
+  rubydo $curwin.cursor = [1, 5]
+  call assert_equal([1, 6], [line('.'), col('.')])
+
+  " Check that movement after setting cursor position keeps current column.
+  normal j
+  call assert_equal([2, 6], [line('.'), col('.')])
+endfunc
index 54e3617a7ad6bd7ec85568090e396f64cd2c8290..c0eadc6372735a8aa6ab443a92bfe08efe75ce24 100644 (file)
@@ -665,3 +665,16 @@ func Test_tcl_exit()
 
   tcl unset bar
 endfunc
+func Test_set_cursor()
+  " Check that setting the cursor position works.
+  new
+  call setline(1, ['first line', 'second line'])
+  normal gg
+  tcldo $::vim::current(window) cursor 1 5
+  call assert_equal([1, 5], [line('.'), col('.')])
+
+  " Check that movement after setting cursor position keeps current column.
+  normal j
+  call assert_equal([2, 5], [line('.'), col('.')])
+endfunc
index 24753d1e5591ed0f77cc74af58242a868a2210a5..81ed54446b194b287ce8cd0a5b4cf96a82aa5147 100644 (file)
@@ -793,6 +793,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    212,
 /**/
     211,
 /**/