diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-10-24 20:07:07 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-10-24 20:07:07 +0200 |
commit | 336bf2b8b269e2591576b9f580e79edb93e23c62 (patch) | |
tree | c2e62950b68cc8a87fd4a888b237d0ffe509191a /src | |
parent | b754b5bf6d9ac1f3654552973aa6f9c11239af3d (diff) | |
download | vim-git-336bf2b8b269e2591576b9f580e79edb93e23c62.tar.gz |
patch 8.1.2211: listener callback "added" argument is not the totalv8.1.2211
Problem: Listener callback "added" argument is not the total. (Andy
Massimino)
Solution: Compute the total. (closes #5105)
Diffstat (limited to 'src')
-rw-r--r-- | src/change.c | 4 | ||||
-rw-r--r-- | src/testdir/test_listener.vim | 9 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 11 insertions, 4 deletions
diff --git a/src/change.c b/src/change.c index caf9db0d7..da6a72b56 100644 --- a/src/change.c +++ b/src/change.c @@ -371,9 +371,9 @@ invoke_listeners(buf_T *buf) if (start > lnum) start = lnum; lnum = dict_get_number(li->li_tv.vval.v_dict, (char_u *)"end"); - if (lnum > end) + if (end < lnum) end = lnum; - added = dict_get_number(li->li_tv.vval.v_dict, (char_u *)"added"); + added += dict_get_number(li->li_tv.vval.v_dict, (char_u *)"added"); } argv[1].v_type = VAR_NUMBER; argv[1].vval.v_number = start; diff --git a/src/testdir/test_listener.vim b/src/testdir/test_listener.vim index 8c265be2d..a7815dc04 100644 --- a/src/testdir/test_listener.vim +++ b/src/testdir/test_listener.vim @@ -1,7 +1,9 @@ " tests for listener_add() and listener_remove() -func s:StoreList(s, l) +func s:StoreList(s, e, a, l) let s:start = a:s + let s:end = a:e + let s:added = a:a let s:text = getline(a:s) let s:list = a:l endfunc @@ -19,7 +21,7 @@ func Test_listening() new call setline(1, ['one', 'two']) let s:list = [] - let id = listener_add({b, s, e, a, l -> s:StoreList(s, l)}) + let id = listener_add({b, s, e, a, l -> s:StoreList(s, e, a, l)}) call setline(1, 'one one') call listener_flush() call assert_equal([{'lnum': 1, 'end': 2, 'col': 1, 'added': 0}], s:list) @@ -65,6 +67,9 @@ func Test_listening() call bufnr()->listener_flush() call assert_equal([{'lnum': 3, 'end': 3, 'col': 1, 'added': 1}, \ {'lnum': 1, 'end': 2, 'col': 1, 'added': 0}], s:list) + call assert_equal(1, s:start) + call assert_equal(3, s:end) + call assert_equal(1, s:added) " an insert just above a previous change that was the last one does not get " merged diff --git a/src/version.c b/src/version.c index 0347a68b4..45c7bc07a 100644 --- a/src/version.c +++ b/src/version.c @@ -742,6 +742,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2211, +/**/ 2210, /**/ 2209, |