@@ -783,10 +783,11 @@ endfunction
783
783
function ! s: syntax ()
784
784
syntax clear
785
785
syntax region plug1 start =/ \% 1l/ end =/ \% 2l/ contains =plugNumber
786
- syntax region plug2 start =/ \% 2l/ end =/ \% 3l/ contains =plugBracket,plugX
786
+ syntax region plug2 start =/ \% 2l/ end =/ \% 3l/ contains =plugBracket,plugX,plugAbort
787
787
syn match plugNumber / [0-9]\+ [0-9.]*/ contained
788
788
syn match plugBracket / [[\] ]/ contained
789
789
syn match plugX / x/ contained
790
+ syn match plugAbort / \~ / contained
790
791
syn match plugDash / ^-\{ 1}\ /
791
792
syn match plugPlus / ^+/
792
793
syn match plugStar / ^*/
@@ -811,6 +812,7 @@ function! s:syntax()
811
812
hi def link plug2 Repeat
812
813
hi def link plugH2 Type
813
814
hi def link plugX Exception
815
+ hi def link plugAbort Ignore
814
816
hi def link plugBracket Structure
815
817
hi def link plugNumber Number
816
818
@@ -908,7 +910,7 @@ function! s:prepare(...)
908
910
endif
909
911
endfor
910
912
911
- call s: job_abort ()
913
+ call s: job_abort (0 )
912
914
if s: switch_in ()
913
915
if b: plug_preview == 1
914
916
pc
@@ -944,6 +946,8 @@ function! s:close_pane()
944
946
if b: plug_preview == 1
945
947
pc
946
948
let b: plug_preview = -1
949
+ elseif exists (' s:jobs' ) && ! empty (s: jobs )
950
+ call s: job_abort (1 )
947
951
else
948
952
bd
949
953
endif
@@ -1326,7 +1330,12 @@ function! s:update_finish()
1326
1330
endif
1327
1331
endfunction
1328
1332
1329
- function ! s: job_abort ()
1333
+ function ! s: mark_aborted (name, message)
1334
+ let attrs = { ' running' : 0 , ' error' : 1 , ' abort' : 1 , ' lines' : [a: message ] }
1335
+ let s: jobs [a: name ] = extend (get (s: jobs , a: name , {}), attrs)
1336
+ endfunction
1337
+
1338
+ function ! s: job_abort (cancel)
1330
1339
if (! s: nvim && ! s: vim8 ) || ! exists (' s:jobs' )
1331
1340
return
1332
1341
endif
@@ -1340,8 +1349,18 @@ function! s:job_abort()
1340
1349
if j .new
1341
1350
call s: rm_rf (g: plugs [name].dir )
1342
1351
endif
1352
+ if a: cancel
1353
+ call s: mark_aborted (name, ' Aborted' )
1354
+ endif
1343
1355
endfor
1344
- let s: jobs = {}
1356
+
1357
+ if a: cancel
1358
+ for todo in values (s: update .todo )
1359
+ let todo .abort = 1
1360
+ endfor
1361
+ else
1362
+ let s: jobs = {}
1363
+ endif
1345
1364
endfunction
1346
1365
1347
1366
function ! s: last_non_empty_line (lines )
@@ -1355,6 +1374,16 @@ function! s:last_non_empty_line(lines)
1355
1374
return ' '
1356
1375
endfunction
1357
1376
1377
+ function ! s: bullet_for (job, ... )
1378
+ if a: job .running
1379
+ return a: job .new ? ' +' : ' *'
1380
+ endif
1381
+ if get (a: job , ' abort' , 0 )
1382
+ return ' ~'
1383
+ endif
1384
+ return a: job .error ? ' x' : get (a: 000 , 0 , ' -' )
1385
+ endfunction
1386
+
1358
1387
function ! s: job_out_cb (self , data) abort
1359
1388
let self = a: self
1360
1389
let data = remove (self .lines , -1 ) . a: data
@@ -1363,10 +1392,9 @@ function! s:job_out_cb(self, data) abort
1363
1392
" To reduce the number of buffer updates
1364
1393
let self .tick = get (self , ' tick' , -1 ) + 1
1365
1394
if ! self .running || self .tick % len (s: jobs ) == 0
1366
- let bullet = self .running ? (self .new ? ' +' : ' *' ) : (self .error ? ' x' : ' -' )
1367
1395
let result = self .error ? join (self .lines , " \n " ) : s: last_non_empty_line (self .lines )
1368
1396
if len (result)
1369
- call s: log (bullet , self .name, result)
1397
+ call s: log (s: bullet_for ( self ) , self .name, result)
1370
1398
endif
1371
1399
endif
1372
1400
endfunction
@@ -1380,7 +1408,7 @@ endfunction
1380
1408
1381
1409
function ! s: job_cb (fn, job, ch , data)
1382
1410
if ! s: plug_window_exists () " plug window closed
1383
- return s: job_abort ()
1411
+ return s: job_abort (0 )
1384
1412
endif
1385
1413
call call (a: fn , [a: job , a: data ])
1386
1414
endfunction
@@ -1452,17 +1480,16 @@ function! s:reap(name)
1452
1480
endif
1453
1481
1454
1482
let more = len (get (job, ' queue' , []))
1455
- let bullet = job.error ? ' x' : more ? (job.new ? ' +' : ' *' ) : ' -'
1456
1483
let result = job.error ? join (job.lines , " \n " ) : s: last_non_empty_line (job.lines )
1457
1484
if len (result)
1458
- call s: log (bullet , a: name , result)
1485
+ call s: log (s: bullet_for (job) , a: name , result)
1459
1486
endif
1460
1487
1461
1488
if ! job.error && more
1462
1489
let job.spec.queue = job.queue
1463
1490
let s: update .todo [a: name ] = job.spec
1464
1491
else
1465
- let s: update .bar .= job. error ? ' x ' : ' = '
1492
+ let s: update .bar .= s: bullet_for ( job, ' = ' )
1466
1493
call s: bar ()
1467
1494
endif
1468
1495
endfunction
@@ -1541,6 +1568,12 @@ while 1 " Without TCO, Vim stack is bound to explode
1541
1568
1542
1569
let name = keys (s: update .todo )[0 ]
1543
1570
let spec = remove (s: update .todo , name)
1571
+ if get (spec, ' abort' , 0 )
1572
+ call s: mark_aborted (name, ' Skipped' )
1573
+ call s: reap (name)
1574
+ continue
1575
+ endif
1576
+
1544
1577
let queue = get (spec, ' queue' , [])
1545
1578
let new = empty (globpath (spec.dir , ' .git' , 1 ))
1546
1579
0 commit comments