Mercurial > vim
comparison src/testdir/test_python2.vim @ 16080:bf8cf5c3b784 v8.1.1045
patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
commit https://github.com/vim/vim/commit/63dbfd33c1d47400c62775842b5b750ee69e2383
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 23 17:41:59 2019 +0100
patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 23 Mar 2019 17:45:05 +0100 |
parents | a83c4b1f8ea2 |
children | 402b714cb919 |
comparison
equal
deleted
inserted
replaced
16079:3830b36ff14f | 16080:bf8cf5c3b784 |
---|---|
69 if 0 | 69 if 0 |
70 python import vim | 70 python import vim |
71 endif | 71 endif |
72 call assert_equal(0, &pyxversion) " This assertion would have failed with Vim 8.0.0251. (pyxversion was introduced in 8.0.0251.) | 72 call assert_equal(0, &pyxversion) " This assertion would have failed with Vim 8.0.0251. (pyxversion was introduced in 8.0.0251.) |
73 endfunc | 73 endfunc |
74 | |
75 func _SetUpHiddenBuffer() | |
76 py import vim | |
77 new | |
78 edit hidden | |
79 setlocal bufhidden=hide | |
80 | |
81 enew | |
82 let lnum = 0 | |
83 while lnum < 10 | |
84 call append( 1, string( lnum ) ) | |
85 let lnum = lnum + 1 | |
86 endwhile | |
87 normal G | |
88 | |
89 call assert_equal( line( '.' ), 11 ) | |
90 endfunc | |
91 | |
92 func Test_Write_To_HiddenBuffer_Does_Not_Fix_Cursor_Clear() | |
93 call _SetUpHiddenBuffer() | |
94 py vim.buffers[ int( vim.eval( 'bufnr("hidden")' ) ) ][:] = None | |
95 call assert_equal( line( '.' ), 11 ) | |
96 bwipe! | |
97 endfunc | |
98 | |
99 func Test_Write_To_HiddenBuffer_Does_Not_Fix_Cursor_List() | |
100 call _SetUpHiddenBuffer() | |
101 py vim.buffers[ int( vim.eval( 'bufnr("hidden")' ) ) ][:] = [ 'test' ] | |
102 call assert_equal( line( '.' ), 11 ) | |
103 bwipe! | |
104 endfunc | |
105 | |
106 func Test_Write_To_HiddenBuffer_Does_Not_Fix_Cursor_Str() | |
107 call _SetUpHiddenBuffer() | |
108 py vim.buffers[ int( vim.eval( 'bufnr("hidden")' ) ) ][0] = 'test' | |
109 call assert_equal( line( '.' ), 11 ) | |
110 bwipe! | |
111 endfunc | |
112 | |
113 func Test_Write_To_HiddenBuffer_Does_Not_Fix_Cursor_ClearLine() | |
114 call _SetUpHiddenBuffer() | |
115 py vim.buffers[ int( vim.eval( 'bufnr("hidden")' ) ) ][0] = None | |
116 call assert_equal( line( '.' ), 11 ) | |
117 bwipe! | |
118 endfunc | |
119 | |
120 func _SetUpVisibleBuffer() | |
121 py import vim | |
122 new | |
123 let lnum = 0 | |
124 while lnum < 10 | |
125 call append( 1, string( lnum ) ) | |
126 let lnum = lnum + 1 | |
127 endwhile | |
128 normal G | |
129 call assert_equal( line( '.' ), 11 ) | |
130 endfunc | |
131 | |
132 func Test_Write_To_Current_Buffer_Fixes_Cursor_Clear() | |
133 call _SetUpVisibleBuffer() | |
134 | |
135 py vim.current.buffer[:] = None | |
136 call assert_equal( line( '.' ), 1 ) | |
137 | |
138 bwipe! | |
139 endfunc | |
140 | |
141 func Test_Write_To_Current_Buffer_Fixes_Cursor_List() | |
142 call _SetUpVisibleBuffer() | |
143 | |
144 py vim.current.buffer[:] = [ 'test' ] | |
145 call assert_equal( line( '.' ), 1 ) | |
146 | |
147 bwipe! | |
148 endfunction | |
149 | |
150 func Test_Write_To_Current_Buffer_Fixes_Cursor_Str() | |
151 call _SetUpVisibleBuffer() | |
152 | |
153 py vim.current.buffer[-1] = None | |
154 call assert_equal( line( '.' ), 10 ) | |
155 | |
156 bwipe! | |
157 endfunction |