To: vim_dev@googlegroups.com Subject: Patch 8.1.2211 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.2211 Problem: Listener callback "added" argument is not the total. (Andy Massimino) Solution: Compute the total. (closes #5105) Files: src/change.c, src/testdir/test_listener.vim *** ../vim-8.1.2210/src/change.c 2019-10-09 22:52:48.992043788 +0200 --- src/change.c 2019-10-24 20:05:58.599324286 +0200 *************** *** 371,379 **** if (start > lnum) start = lnum; lnum = dict_get_number(li->li_tv.vval.v_dict, (char_u *)"end"); ! if (lnum > end) end = lnum; ! 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; --- 371,379 ---- if (start > lnum) start = lnum; lnum = dict_get_number(li->li_tv.vval.v_dict, (char_u *)"end"); ! if (end < lnum) end = lnum; ! 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; *** ../vim-8.1.2210/src/testdir/test_listener.vim 2019-09-08 15:27:17.552004765 +0200 --- src/testdir/test_listener.vim 2019-10-24 20:05:31.531414113 +0200 *************** *** 1,7 **** " tests for listener_add() and listener_remove() ! func s:StoreList(s, l) let s:start = a:s let s:text = getline(a:s) let s:list = a:l endfunc --- 1,9 ---- " tests for listener_add() and listener_remove() ! 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,25 **** new call setline(1, ['one', 'two']) let s:list = [] ! let id = listener_add({b, s, e, a, l -> s:StoreList(s, l)}) call setline(1, 'one one') call listener_flush() call assert_equal([{'lnum': 1, 'end': 2, 'col': 1, 'added': 0}], s:list) --- 21,27 ---- new call setline(1, ['one', 'two']) let s:list = [] ! 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,70 **** --- 67,75 ---- 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 *** ../vim-8.1.2210/src/version.c 2019-10-24 19:24:56.531366030 +0200 --- src/version.c 2019-10-24 20:06:16.547264637 +0200 *************** *** 743,744 **** --- 743,746 ---- { /* Add new patch number below this line */ + /**/ + 2211, /**/ -- Are leaders born or made? And if they're made, can we return them under warranty? (Scott Adams - The Dilbert principle) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///