Skip to content

Commit 336bf2b

Browse files
committed
patch 8.1.2211: listener callback "added" argument is not the total
Problem: Listener callback "added" argument is not the total. (Andy Massimino) Solution: Compute the total. (closes #5105)
1 parent b754b5b commit 336bf2b

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/change.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,9 @@ invoke_listeners(buf_T *buf)
371371
if (start > lnum)
372372
start = lnum;
373373
lnum = dict_get_number(li->li_tv.vval.v_dict, (char_u *)"end");
374-
if (lnum > end)
374+
if (end < lnum)
375375
end = lnum;
376-
added = dict_get_number(li->li_tv.vval.v_dict, (char_u *)"added");
376+
added += dict_get_number(li->li_tv.vval.v_dict, (char_u *)"added");
377377
}
378378
argv[1].v_type = VAR_NUMBER;
379379
argv[1].vval.v_number = start;

src/testdir/test_listener.vim

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
" tests for listener_add() and listener_remove()
22

3-
func s:StoreList(s, l)
3+
func s:StoreList(s, e, a, l)
44
let s:start = a:s
5+
let s:end = a:e
6+
let s:added = a:a
57
let s:text = getline(a:s)
68
let s:list = a:l
79
endfunc
@@ -19,7 +21,7 @@ func Test_listening()
1921
new
2022
call setline(1, ['one', 'two'])
2123
let s:list = []
22-
let id = listener_add({b, s, e, a, l -> s:StoreList(s, l)})
24+
let id = listener_add({b, s, e, a, l -> s:StoreList(s, e, a, l)})
2325
call setline(1, 'one one')
2426
call listener_flush()
2527
call assert_equal([{'lnum': 1, 'end': 2, 'col': 1, 'added': 0}], s:list)
@@ -65,6 +67,9 @@ func Test_listening()
6567
call bufnr()->listener_flush()
6668
call assert_equal([{'lnum': 3, 'end': 3, 'col': 1, 'added': 1},
6769
\ {'lnum': 1, 'end': 2, 'col': 1, 'added': 0}], s:list)
70+
call assert_equal(1, s:start)
71+
call assert_equal(3, s:end)
72+
call assert_equal(1, s:added)
6873

6974
" an insert just above a previous change that was the last one does not get
7075
" merged

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
2211,
744746
/**/
745747
2210,
746748
/**/

0 commit comments

Comments
 (0)