summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0998
blob: 6ec1ac1262e2f3d3d166e16b3cf22390e2b35f1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0998
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.0998
Problem:    getcurpos() unexpectedly changes "curswant".
Solution:   Save and restore "curswant". (closes #4069)
Files:	    src/evalfunc.c, src/testdir/test_visual.vim


*** ../vim-8.1.0997/src/evalfunc.c	2019-03-05 12:24:04.795965374 +0100
--- src/evalfunc.c	2019-03-07 11:22:40.709060946 +0100
***************
*** 5474,5482 ****
--- 5474,5496 ----
  							      (varnumber_T)0);
  	if (getcurpos)
  	{
+ 	    int	    save_set_curswant = curwin->w_set_curswant;
+ 	    colnr_T save_curswant = curwin->w_curswant;
+ 	    colnr_T save_virtcol = curwin->w_virtcol;
+ 
  	    update_curswant();
  	    list_append_number(l, curwin->w_curswant == MAXCOL ?
  		    (varnumber_T)MAXCOL : (varnumber_T)curwin->w_curswant + 1);
+ 
+ 	    // Do not change "curswant", as it is unexpected that a get
+ 	    // function has a side effect.
+ 	    if (save_set_curswant)
+ 	    {
+ 		curwin->w_set_curswant = save_set_curswant;
+ 		curwin->w_curswant = save_curswant;
+ 		curwin->w_virtcol = save_virtcol;
+ 		curwin->w_valid &= ~VALID_VIRTCOL;
+ 	    }
  	}
      }
      else
*** ../vim-8.1.0997/src/testdir/test_visual.vim	2019-01-24 17:59:35.143217444 +0100
--- src/testdir/test_visual.vim	2019-03-07 11:19:56.382273108 +0100
***************
*** 1,8 ****
  " Tests for various Visual mode.
- if !has('visual')
-   finish
- endif
- 
  
  func Test_block_shift_multibyte()
    " Uses double-wide character.
--- 1,4 ----
***************
*** 397,399 ****
--- 393,406 ----
  
    bwipe!
  endfunc
+ 
+ func Test_curswant_not_changed()
+   new
+   call setline(1, ['one', 'two'])
+   au InsertLeave * call getcurpos()
+   call feedkeys("gg0\<C-V>jI123 \<Esc>j", 'xt')
+   call assert_equal([0, 2, 1, 0, 1], getcurpos())
+ 
+   bwipe!
+   au! InsertLeave
+ endfunc
*** ../vim-8.1.0997/src/version.c	2019-03-07 06:40:23.950955576 +0100
--- src/version.c	2019-03-07 11:21:38.637518405 +0100
***************
*** 781,782 ****
--- 781,784 ----
  {   /* Add new patch number below this line */
+ /**/
+     998,
  /**/

-- 
Nothing is fool-proof to a sufficiently talented fool.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///