diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-03-23 17:41:59 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-03-23 17:41:59 +0100 |
commit | 63dbfd33c1d47400c62775842b5b750ee69e2383 (patch) | |
tree | 37c30be324222ed4a7134224f6878af9c7001786 /src/testdir/test_python2.vim | |
parent | c3e92c161d6394d126a334011526c02e8c3f655f (diff) |
patch 8.1.1045: E315 ml_get error when using Python and hidden bufferv8.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)
Diffstat (limited to 'src/testdir/test_python2.vim')
-rw-r--r-- | src/testdir/test_python2.vim | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/src/testdir/test_python2.vim b/src/testdir/test_python2.vim index 43c89c972a..97b44f2eba 100644 --- a/src/testdir/test_python2.vim +++ b/src/testdir/test_python2.vim @@ -71,3 +71,87 @@ func Test_skipped_python_command_does_not_affect_pyxversion() 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 |