comparison src/testdir/test_signs.vim @ 15519:89e76a598b30 v8.1.0767

patch 8.1.0767: when deleting lines at the bottom signs are misplaced commit https://github.com/vim/vim/commit/c771bf901622064dc27421b04853e16b6914a295 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jan 17 17:36:45 2019 +0100 patch 8.1.0767: when deleting lines at the bottom signs are misplaced Problem: When deleting lines at the bottom signs are misplaced. Solution: Properly update the line number of signs at the end of a buffer after a delete/undo operation. (Yegappan Lakshmanan, closes #3798)
author Bram Moolenaar <Bram@vim.org>
date Thu, 17 Jan 2019 17:45:06 +0100
parents 51b3c36b0523
children 9e0154efac3a
comparison
equal deleted inserted replaced
15518:a99eedb83c56 15519:89e76a598b30
1200 " Test for auto-adjusting the line number of a placed sign. 1200 " Test for auto-adjusting the line number of a placed sign.
1201 func Test_sign_lnum_adjust() 1201 func Test_sign_lnum_adjust()
1202 enew! | only! 1202 enew! | only!
1203 1203
1204 sign define sign1 text=#> linehl=Comment 1204 sign define sign1 text=#> linehl=Comment
1205 call setline(1, ['A', 'B', 'C', 'D']) 1205 call setline(1, ['A', 'B', 'C', 'D', 'E'])
1206 exe 'sign place 5 line=3 name=sign1 buffer=' . bufnr('') 1206 exe 'sign place 5 line=3 name=sign1 buffer=' . bufnr('')
1207 let l = sign_getplaced(bufnr('')) 1207 let l = sign_getplaced(bufnr(''))
1208 call assert_equal(3, l[0].signs[0].lnum) 1208 call assert_equal(3, l[0].signs[0].lnum)
1209 1209
1210 " Add some lines before the sign and check the sign line number 1210 " Add some lines before the sign and check the sign line number
1211 call append(2, ['AA', 'AB', 'AC']) 1211 call append(2, ['BA', 'BB', 'BC'])
1212 let l = sign_getplaced(bufnr('')) 1212 let l = sign_getplaced(bufnr(''))
1213 call assert_equal(6, l[0].signs[0].lnum) 1213 call assert_equal(6, l[0].signs[0].lnum)
1214 1214
1215 " Delete some lines before the sign and check the sign line number 1215 " Delete some lines before the sign and check the sign line number
1216 call deletebufline('%', 1, 2) 1216 call deletebufline('%', 1, 2)
1217 let l = sign_getplaced(bufnr('')) 1217 let l = sign_getplaced(bufnr(''))
1218 call assert_equal(4, l[0].signs[0].lnum) 1218 call assert_equal(4, l[0].signs[0].lnum)
1219
1220 " Insert some lines after the sign and check the sign line number
1221 call append(5, ['DA', 'DB'])
1222 let l = sign_getplaced(bufnr(''))
1223 call assert_equal(4, l[0].signs[0].lnum)
1224
1225 " Delete some lines after the sign and check the sign line number
1226 call deletebufline('', 6, 7)
1227 let l = sign_getplaced(bufnr(''))
1228 call assert_equal(4, l[0].signs[0].lnum)
1229
1230 " Break the undo. Otherwise the undo operation below will undo all the
1231 " changes made by this function.
1232 let &undolevels=&undolevels
1233
1234 " Delete the line with the sign
1235 call deletebufline('', 4)
1236 let l = sign_getplaced(bufnr(''))
1237 call assert_equal(4, l[0].signs[0].lnum)
1238
1239 " Undo the delete operation
1240 undo
1241 let l = sign_getplaced(bufnr(''))
1242 call assert_equal(5, l[0].signs[0].lnum)
1243
1244 " Break the undo
1245 let &undolevels=&undolevels
1246
1247 " Delete few lines at the end of the buffer including the line with the sign
1248 " Sign line number should not change (as it is placed outside of the buffer)
1249 call deletebufline('', 3, 6)
1250 let l = sign_getplaced(bufnr(''))
1251 call assert_equal(5, l[0].signs[0].lnum)
1252
1253 " Undo the delete operation. Sign should be restored to the previous line
1254 undo
1255 let l = sign_getplaced(bufnr(''))
1256 call assert_equal(5, l[0].signs[0].lnum)
1219 1257
1220 sign unplace * group=* 1258 sign unplace * group=*
1221 sign undefine sign1 1259 sign undefine sign1
1222 enew! 1260 enew!
1223 endfunc 1261 endfunc