summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.1045
blob: 753c1ed1fbdc99aaeb7b626fb0ef78c0635cc897 (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
To: vim_dev@googlegroups.com
Subject: Patch 8.1.1045
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.1045
Problem:    E315 ml_get error when using Python and hidden buffer.
Solution:   Make sure the cursor position is valid. (Ben Jackson,
            closes #4153, closes #4154)
Files:	    src/if_py_both.h, src/testdir/test_python2.vim,
            src/testdir/test_python3.vim


*** ../vim-8.1.1044/src/if_py_both.h	2019-02-14 13:28:42.143415639 +0100
--- src/if_py_both.h	2019-03-23 17:26:05.958992217 +0100
***************
*** 4392,4398 ****
  	    RAISE_DELETE_LINE_FAIL;
  	else
  	{
! 	    if (buf == curbuf)
  		py_fix_cursor((linenr_T)n, (linenr_T)n + 1, (linenr_T)-1);
  	    if (save_curbuf.br_buf == NULL)
  		/* Only adjust marks if we managed to switch to a window that
--- 4392,4401 ----
  	    RAISE_DELETE_LINE_FAIL;
  	else
  	{
! 	    if (buf == curbuf && (save_curwin != NULL
! 					   || save_curbuf.br_buf == NULL))
! 		// Using an existing window for the buffer, adjust the cursor
! 		// position.
  		py_fix_cursor((linenr_T)n, (linenr_T)n + 1, (linenr_T)-1);
  	    if (save_curbuf.br_buf == NULL)
  		/* Only adjust marks if we managed to switch to a window that
***************
*** 4642,4648 ****
  						  (long)MAXLNUM, (long)extra);
  	changed_lines((linenr_T)lo, 0, (linenr_T)hi, (long)extra);
  
! 	if (buf == curbuf)
  	    py_fix_cursor((linenr_T)lo, (linenr_T)hi, (linenr_T)extra);
  
  	/* END of region without "return". */
--- 4645,4654 ----
  						  (long)MAXLNUM, (long)extra);
  	changed_lines((linenr_T)lo, 0, (linenr_T)hi, (long)extra);
  
! 	if (buf == curbuf && (save_curwin != NULL
! 					   || save_curbuf.br_buf == NULL))
! 	    // Using an existing window for the buffer, adjust the cursor
! 	    // position.
  	    py_fix_cursor((linenr_T)lo, (linenr_T)hi, (linenr_T)extra);
  
  	/* END of region without "return". */
*** ../vim-8.1.1044/src/testdir/test_python2.vim	2019-02-18 22:04:52.949609091 +0100
--- src/testdir/test_python2.vim	2019-03-23 17:19:39.117394146 +0100
***************
*** 71,73 ****
--- 71,157 ----
    endif
    call assert_equal(0, &pyxversion)  " This assertion would have failed with Vim 8.0.0251. (pyxversion was introduced in 8.0.0251.)
  endfunc
+ 
+ func _SetUpHiddenBuffer()
+   py import vim
+   new
+   edit hidden
+   setlocal bufhidden=hide
+ 
+   enew
+   let lnum = 0
+   while lnum < 10
+     call append( 1, string( lnum ) )
+     let lnum = lnum + 1
+   endwhile
+   normal G
+ 
+   call assert_equal( line( '.' ), 11 )
+ endfunc
+ 
+ func Test_Write_To_HiddenBuffer_Does_Not_Fix_Cursor_Clear()
+   call _SetUpHiddenBuffer()
+   py vim.buffers[ int( vim.eval( 'bufnr("hidden")' ) ) ][:] = None
+   call assert_equal( line( '.' ), 11 )
+   bwipe!
+ endfunc
+ 
+ func Test_Write_To_HiddenBuffer_Does_Not_Fix_Cursor_List()
+   call _SetUpHiddenBuffer()
+   py vim.buffers[ int( vim.eval( 'bufnr("hidden")' ) ) ][:] = [ 'test' ]
+   call assert_equal( line( '.' ), 11 )
+   bwipe!
+ endfunc
+ 
+ func Test_Write_To_HiddenBuffer_Does_Not_Fix_Cursor_Str()
+   call _SetUpHiddenBuffer()
+   py vim.buffers[ int( vim.eval( 'bufnr("hidden")' ) ) ][0] = 'test'
+   call assert_equal( line( '.' ), 11 )
+   bwipe!
+ endfunc
+ 
+ func Test_Write_To_HiddenBuffer_Does_Not_Fix_Cursor_ClearLine()
+   call _SetUpHiddenBuffer()
+   py vim.buffers[ int( vim.eval( 'bufnr("hidden")' ) ) ][0] = None
+   call assert_equal( line( '.' ), 11 )
+   bwipe!
+ endfunc
+ 
+ func _SetUpVisibleBuffer()
+   py import vim
+   new
+   let lnum = 0
+   while lnum < 10
+     call append( 1, string( lnum ) )
+     let lnum = lnum + 1
+   endwhile
+   normal G
+   call assert_equal( line( '.' ), 11 )
+ endfunc
+ 
+ func Test_Write_To_Current_Buffer_Fixes_Cursor_Clear()
+   call _SetUpVisibleBuffer()
+ 
+   py vim.current.buffer[:] = None
+   call assert_equal( line( '.' ), 1 )
+ 
+   bwipe!
+ endfunc
+ 
+ func Test_Write_To_Current_Buffer_Fixes_Cursor_List()
+   call _SetUpVisibleBuffer()
+ 
+   py vim.current.buffer[:] = [ 'test' ]
+   call assert_equal( line( '.' ), 1 )
+ 
+   bwipe!
+ endfunction
+ 
+ func Test_Write_To_Current_Buffer_Fixes_Cursor_Str()
+   call _SetUpVisibleBuffer()
+ 
+   py vim.current.buffer[-1] = None
+   call assert_equal( line( '.' ), 10 )
+ 
+   bwipe!
+ endfunction
*** ../vim-8.1.1044/src/testdir/test_python3.vim	2019-02-18 22:04:52.949609091 +0100
--- src/testdir/test_python3.vim	2019-03-23 17:19:39.117394146 +0100
***************
*** 71,73 ****
--- 71,157 ----
    endif
    call assert_equal(0, &pyxversion)  " This assertion would have failed with Vim 8.0.0251. (pyxversion was introduced in 8.0.0251.)
  endfunc
+ 
+ func _SetUpHiddenBuffer()
+   py3 import vim
+   new
+   edit hidden
+   setlocal bufhidden=hide
+ 
+   enew
+   let lnum = 0
+   while lnum < 10
+     call append( 1, string( lnum ) )
+     let lnum = lnum + 1
+   endwhile
+   normal G
+ 
+   call assert_equal( line( '.' ), 11 )
+ endfunc
+ 
+ func Test_Write_To_HiddenBuffer_Does_Not_Fix_Cursor_Clear()
+   call _SetUpHiddenBuffer()
+   py3 vim.buffers[ int( vim.eval( 'bufnr("hidden")' ) ) ][:] = None
+   call assert_equal( line( '.' ), 11 )
+   bwipe!
+ endfunc
+ 
+ func Test_Write_To_HiddenBuffer_Does_Not_Fix_Cursor_List()
+   call _SetUpHiddenBuffer()
+   py3 vim.buffers[ int( vim.eval( 'bufnr("hidden")' ) ) ][:] = [ 'test' ]
+   call assert_equal( line( '.' ), 11 )
+   bwipe!
+ endfunc
+ 
+ func Test_Write_To_HiddenBuffer_Does_Not_Fix_Cursor_Str()
+   call _SetUpHiddenBuffer()
+   py3 vim.buffers[ int( vim.eval( 'bufnr("hidden")' ) ) ][0] = 'test'
+   call assert_equal( line( '.' ), 11 )
+   bwipe!
+ endfunc
+ 
+ func Test_Write_To_HiddenBuffer_Does_Not_Fix_Cursor_ClearLine()
+   call _SetUpHiddenBuffer()
+   py3 vim.buffers[ int( vim.eval( 'bufnr("hidden")' ) ) ][0] = None
+   call assert_equal( line( '.' ), 11 )
+   bwipe!
+ endfunc
+ 
+ func _SetUpVisibleBuffer()
+   py3 import vim
+   new
+   let lnum = 0
+   while lnum < 10
+     call append( 1, string( lnum ) )
+     let lnum = lnum + 1
+   endwhile
+   normal G
+   call assert_equal( line( '.' ), 11 )
+ endfunc
+ 
+ func Test_Write_To_Current_Buffer_Fixes_Cursor_Clear()
+   call _SetUpVisibleBuffer()
+ 
+   py3 vim.current.buffer[:] = None
+   call assert_equal( line( '.' ), 1 )
+ 
+   bwipe!
+ endfunc
+ 
+ func Test_Write_To_Current_Buffer_Fixes_Cursor_List()
+   call _SetUpVisibleBuffer()
+ 
+   py3 vim.current.buffer[:] = [ 'test' ]
+   call assert_equal( line( '.' ), 1 )
+ 
+   bwipe!
+ endfunction
+ 
+ func Test_Write_To_Current_Buffer_Fixes_Cursor_Str()
+   call _SetUpVisibleBuffer()
+ 
+   py3 vim.current.buffer[-1] = None
+   call assert_equal( line( '.' ), 10 )
+ 
+   bwipe!
+ endfunction
*** ../vim-8.1.1044/src/version.c	2019-03-23 14:23:02.138361658 +0100
--- src/version.c	2019-03-23 17:40:28.001674801 +0100
***************
*** 777,778 ****
--- 777,780 ----
  {   /* Add new patch number below this line */
+ /**/
+     1045,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
106. When told to "go to your room" you inform your parents that you
     can't...because you were kicked out and banned.

 /// 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    ///