comparison src/testdir/test_signs.vim @ 16978:15bc5a64bd50 v8.1.1489

patch 8.1.1489: sign order wrong when priority was changed commit https://github.com/vim/vim/commit/64416127fc184b5544530afe818722679158f059 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jun 7 21:37:13 2019 +0200 patch 8.1.1489: sign order wrong when priority was changed Problem: Sign order wrong when priority was changed. Solution: Reorder signs when priority is changed. (Yegappan Lakshmanan, closes #4502)
author Bram Moolenaar <Bram@vim.org>
date Fri, 07 Jun 2019 21:45:05 +0200
parents 1689b52cf297
children f38fcbf343ce
comparison
equal deleted inserted replaced
16977:9d3ff8fd2018 16978:15bc5a64bd50
1181 \ 'priority' : 50}, 1181 \ 'priority' : 50},
1182 \ {'id' : 3, 'name' : 'sign3', 'lnum' : 11, 'group' : '', 1182 \ {'id' : 3, 'name' : 'sign3', 'lnum' : 11, 'group' : '',
1183 \ 'priority' : 10}], 1183 \ 'priority' : 10}],
1184 \ s[0].signs) 1184 \ s[0].signs)
1185 1185
1186 call sign_unplace('*')
1187
1188 " Three signs on different lines with changing priorities
1189 call sign_place(1, '', 'sign1', 'Xsign',
1190 \ {'lnum' : 11, 'priority' : 50})
1191 call sign_place(2, '', 'sign2', 'Xsign',
1192 \ {'lnum' : 12, 'priority' : 60})
1193 call sign_place(3, '', 'sign3', 'Xsign',
1194 \ {'lnum' : 13, 'priority' : 70})
1195 call sign_place(2, '', 'sign2', 'Xsign',
1196 \ {'lnum' : 12, 'priority' : 40})
1197 call sign_place(3, '', 'sign3', 'Xsign',
1198 \ {'lnum' : 13, 'priority' : 30})
1199 call sign_place(1, '', 'sign1', 'Xsign',
1200 \ {'lnum' : 11, 'priority' : 50})
1201 let s = sign_getplaced('Xsign', {'group' : '*'})
1202 call assert_equal([
1203 \ {'id' : 1, 'name' : 'sign1', 'lnum' : 11, 'group' : '',
1204 \ 'priority' : 50},
1205 \ {'id' : 2, 'name' : 'sign2', 'lnum' : 12, 'group' : '',
1206 \ 'priority' : 40},
1207 \ {'id' : 3, 'name' : 'sign3', 'lnum' : 13, 'group' : '',
1208 \ 'priority' : 30}],
1209 \ s[0].signs)
1210
1211 call sign_unplace('*')
1212
1213 " Two signs on the same line with changing priorities
1214 call sign_place(1, '', 'sign1', 'Xsign',
1215 \ {'lnum' : 4, 'priority' : 20})
1216 call sign_place(2, '', 'sign2', 'Xsign',
1217 \ {'lnum' : 4, 'priority' : 30})
1218 let s = sign_getplaced('Xsign', {'group' : '*'})
1219 call assert_equal([
1220 \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
1221 \ 'priority' : 30},
1222 \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
1223 \ 'priority' : 20}],
1224 \ s[0].signs)
1225 " Change the priority of the last sign to highest
1226 call sign_place(1, '', 'sign1', 'Xsign',
1227 \ {'lnum' : 4, 'priority' : 40})
1228 let s = sign_getplaced('Xsign', {'group' : '*'})
1229 call assert_equal([
1230 \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
1231 \ 'priority' : 40},
1232 \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
1233 \ 'priority' : 30}],
1234 \ s[0].signs)
1235 " Change the priority of the first sign to lowest
1236 call sign_place(1, '', 'sign1', 'Xsign',
1237 \ {'lnum' : 4, 'priority' : 25})
1238 let s = sign_getplaced('Xsign', {'group' : '*'})
1239 call assert_equal([
1240 \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
1241 \ 'priority' : 30},
1242 \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
1243 \ 'priority' : 25}],
1244 \ s[0].signs)
1245 call sign_place(1, '', 'sign1', 'Xsign',
1246 \ {'lnum' : 4, 'priority' : 45})
1247 call sign_place(2, '', 'sign2', 'Xsign',
1248 \ {'lnum' : 4, 'priority' : 55})
1249 let s = sign_getplaced('Xsign', {'group' : '*'})
1250 call assert_equal([
1251 \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
1252 \ 'priority' : 55},
1253 \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
1254 \ 'priority' : 45}],
1255 \ s[0].signs)
1256
1257 call sign_unplace('*')
1258
1259 " Three signs on the same line with changing priorities
1260 call sign_place(1, '', 'sign1', 'Xsign',
1261 \ {'lnum' : 4, 'priority' : 40})
1262 call sign_place(2, '', 'sign2', 'Xsign',
1263 \ {'lnum' : 4, 'priority' : 30})
1264 call sign_place(3, '', 'sign3', 'Xsign',
1265 \ {'lnum' : 4, 'priority' : 20})
1266 let s = sign_getplaced('Xsign', {'group' : '*'})
1267 call assert_equal([
1268 \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
1269 \ 'priority' : 40},
1270 \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
1271 \ 'priority' : 30},
1272 \ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
1273 \ 'priority' : 20}],
1274 \ s[0].signs)
1275
1276 " Change the priority of the middle sign to the highest
1277 call sign_place(2, '', 'sign2', 'Xsign',
1278 \ {'lnum' : 4, 'priority' : 50})
1279 let s = sign_getplaced('Xsign', {'group' : '*'})
1280 call assert_equal([
1281 \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
1282 \ 'priority' : 50},
1283 \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
1284 \ 'priority' : 40},
1285 \ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
1286 \ 'priority' : 20}],
1287 \ s[0].signs)
1288
1289 " Change the priority of the middle sign to the lowest
1290 call sign_place(1, '', 'sign1', 'Xsign',
1291 \ {'lnum' : 4, 'priority' : 15})
1292 let s = sign_getplaced('Xsign', {'group' : '*'})
1293 call assert_equal([
1294 \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
1295 \ 'priority' : 50},
1296 \ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
1297 \ 'priority' : 20},
1298 \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
1299 \ 'priority' : 15}],
1300 \ s[0].signs)
1301
1302 " Change the priority of the last sign to the highest
1303 call sign_place(1, '', 'sign1', 'Xsign',
1304 \ {'lnum' : 4, 'priority' : 55})
1305 let s = sign_getplaced('Xsign', {'group' : '*'})
1306 call assert_equal([
1307 \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
1308 \ 'priority' : 55},
1309 \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
1310 \ 'priority' : 50},
1311 \ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
1312 \ 'priority' : 20}],
1313 \ s[0].signs)
1314
1315 " Change the priority of the first sign to the lowest
1316 call sign_place(1, '', 'sign1', 'Xsign',
1317 \ {'lnum' : 4, 'priority' : 15})
1318 let s = sign_getplaced('Xsign', {'group' : '*'})
1319 call assert_equal([
1320 \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
1321 \ 'priority' : 50},
1322 \ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
1323 \ 'priority' : 20},
1324 \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
1325 \ 'priority' : 15}],
1326 \ s[0].signs)
1327
1328 call sign_unplace('*')
1329
1330 " Three signs on the same line with changing priorities along with other
1331 " signs
1332 call sign_place(1, '', 'sign1', 'Xsign',
1333 \ {'lnum' : 2, 'priority' : 10})
1334 call sign_place(2, '', 'sign1', 'Xsign',
1335 \ {'lnum' : 4, 'priority' : 30})
1336 call sign_place(3, '', 'sign2', 'Xsign',
1337 \ {'lnum' : 4, 'priority' : 20})
1338 call sign_place(4, '', 'sign3', 'Xsign',
1339 \ {'lnum' : 4, 'priority' : 25})
1340 call sign_place(5, '', 'sign2', 'Xsign',
1341 \ {'lnum' : 6, 'priority' : 80})
1342 let s = sign_getplaced('Xsign', {'group' : '*'})
1343 call assert_equal([
1344 \ {'id' : 1, 'name' : 'sign1', 'lnum' : 2, 'group' : '',
1345 \ 'priority' : 10},
1346 \ {'id' : 2, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
1347 \ 'priority' : 30},
1348 \ {'id' : 4, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
1349 \ 'priority' : 25},
1350 \ {'id' : 3, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
1351 \ 'priority' : 20},
1352 \ {'id' : 5, 'name' : 'sign2', 'lnum' : 6, 'group' : '',
1353 \ 'priority' : 80}],
1354 \ s[0].signs)
1355
1356 " Change the priority of the first sign to lowest
1357 call sign_place(2, '', 'sign1', 'Xsign',
1358 \ {'lnum' : 4, 'priority' : 15})
1359 let s = sign_getplaced('Xsign', {'group' : '*'})
1360 call assert_equal([
1361 \ {'id' : 1, 'name' : 'sign1', 'lnum' : 2, 'group' : '',
1362 \ 'priority' : 10},
1363 \ {'id' : 4, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
1364 \ 'priority' : 25},
1365 \ {'id' : 3, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
1366 \ 'priority' : 20},
1367 \ {'id' : 2, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
1368 \ 'priority' : 15},
1369 \ {'id' : 5, 'name' : 'sign2', 'lnum' : 6, 'group' : '',
1370 \ 'priority' : 80}],
1371 \ s[0].signs)
1372
1373 " Change the priority of the last sign to highest
1374 call sign_place(2, '', 'sign1', 'Xsign',
1375 \ {'lnum' : 4, 'priority' : 30})
1376 let s = sign_getplaced('Xsign', {'group' : '*'})
1377 call assert_equal([
1378 \ {'id' : 1, 'name' : 'sign1', 'lnum' : 2, 'group' : '',
1379 \ 'priority' : 10},
1380 \ {'id' : 2, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
1381 \ 'priority' : 30},
1382 \ {'id' : 4, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
1383 \ 'priority' : 25},
1384 \ {'id' : 3, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
1385 \ 'priority' : 20},
1386 \ {'id' : 5, 'name' : 'sign2', 'lnum' : 6, 'group' : '',
1387 \ 'priority' : 80}],
1388 \ s[0].signs)
1389
1390 " Change the priority of the middle sign to lowest
1391 call sign_place(4, '', 'sign3', 'Xsign',
1392 \ {'lnum' : 4, 'priority' : 15})
1393 let s = sign_getplaced('Xsign', {'group' : '*'})
1394 call assert_equal([
1395 \ {'id' : 1, 'name' : 'sign1', 'lnum' : 2, 'group' : '',
1396 \ 'priority' : 10},
1397 \ {'id' : 2, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
1398 \ 'priority' : 30},
1399 \ {'id' : 3, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
1400 \ 'priority' : 20},
1401 \ {'id' : 4, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
1402 \ 'priority' : 15},
1403 \ {'id' : 5, 'name' : 'sign2', 'lnum' : 6, 'group' : '',
1404 \ 'priority' : 80}],
1405 \ s[0].signs)
1406
1407 " Change the priority of the middle sign to highest
1408 call sign_place(3, '', 'sign2', 'Xsign',
1409 \ {'lnum' : 4, 'priority' : 35})
1410 let s = sign_getplaced('Xsign', {'group' : '*'})
1411 call assert_equal([
1412 \ {'id' : 1, 'name' : 'sign1', 'lnum' : 2, 'group' : '',
1413 \ 'priority' : 10},
1414 \ {'id' : 3, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
1415 \ 'priority' : 35},
1416 \ {'id' : 2, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
1417 \ 'priority' : 30},
1418 \ {'id' : 4, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
1419 \ 'priority' : 15},
1420 \ {'id' : 5, 'name' : 'sign2', 'lnum' : 6, 'group' : '',
1421 \ 'priority' : 80}],
1422 \ s[0].signs)
1423
1424 call sign_unplace('*')
1425
1426 " Multiple signs with the same priority on the same line
1427 call sign_place(1, '', 'sign1', 'Xsign',
1428 \ {'lnum' : 4, 'priority' : 20})
1429 call sign_place(2, '', 'sign2', 'Xsign',
1430 \ {'lnum' : 4, 'priority' : 20})
1431 call sign_place(3, '', 'sign3', 'Xsign',
1432 \ {'lnum' : 4, 'priority' : 20})
1433 let s = sign_getplaced('Xsign', {'group' : '*'})
1434 call assert_equal([
1435 \ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
1436 \ 'priority' : 20},
1437 \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
1438 \ 'priority' : 20},
1439 \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
1440 \ 'priority' : 20}],
1441 \ s[0].signs)
1442 " Place the last sign again with the same priority
1443 call sign_place(1, '', 'sign1', 'Xsign',
1444 \ {'lnum' : 4, 'priority' : 20})
1445 let s = sign_getplaced('Xsign', {'group' : '*'})
1446 call assert_equal([
1447 \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
1448 \ 'priority' : 20},
1449 \ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
1450 \ 'priority' : 20},
1451 \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
1452 \ 'priority' : 20}],
1453 \ s[0].signs)
1454 " Place the first sign again with the same priority
1455 call sign_place(1, '', 'sign1', 'Xsign',
1456 \ {'lnum' : 4, 'priority' : 20})
1457 let s = sign_getplaced('Xsign', {'group' : '*'})
1458 call assert_equal([
1459 \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
1460 \ 'priority' : 20},
1461 \ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
1462 \ 'priority' : 20},
1463 \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
1464 \ 'priority' : 20}],
1465 \ s[0].signs)
1466 " Place the middle sign again with the same priority
1467 call sign_place(3, '', 'sign3', 'Xsign',
1468 \ {'lnum' : 4, 'priority' : 20})
1469 let s = sign_getplaced('Xsign', {'group' : '*'})
1470 call assert_equal([
1471 \ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
1472 \ 'priority' : 20},
1473 \ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
1474 \ 'priority' : 20},
1475 \ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
1476 \ 'priority' : 20}],
1477 \ s[0].signs)
1478
1479 call sign_unplace('*')
1480
1186 " Place multiple signs with same id on a line with different priority 1481 " Place multiple signs with same id on a line with different priority
1187 call sign_place(1, '', 'sign1', 'Xsign', 1482 call sign_place(1, '', 'sign1', 'Xsign',
1188 \ {'lnum' : 5, 'priority' : 20}) 1483 \ {'lnum' : 5, 'priority' : 20})
1189 call sign_place(1, '', 'sign2', 'Xsign', 1484 call sign_place(1, '', 'sign2', 'Xsign',
1190 \ {'lnum' : 5, 'priority' : 10}) 1485 \ {'lnum' : 5, 'priority' : 10})