Mercurial > vim
comparison src/testdir/test_listener.vim @ 18434:5da355d15b88 v8.1.2211
patch 8.1.2211: listener callback "added" argument is not the total
Commit: https://github.com/vim/vim/commit/336bf2b8b269e2591576b9f580e79edb93e23c62
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Oct 24 20:07:07 2019 +0200
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 24 Oct 2019 20:15:03 +0200 |
parents | d19caa851682 |
children | af795b6a2624 |
comparison
equal
deleted
inserted
replaced
18433:557361ce163e | 18434:5da355d15b88 |
---|---|
1 " tests for listener_add() and listener_remove() | 1 " tests for listener_add() and listener_remove() |
2 | 2 |
3 func s:StoreList(s, l) | 3 func s:StoreList(s, e, a, l) |
4 let s:start = a:s | 4 let s:start = a:s |
5 let s:end = a:e | |
6 let s:added = a:a | |
5 let s:text = getline(a:s) | 7 let s:text = getline(a:s) |
6 let s:list = a:l | 8 let s:list = a:l |
7 endfunc | 9 endfunc |
8 | 10 |
9 func s:AnotherStoreList(l) | 11 func s:AnotherStoreList(l) |
17 | 19 |
18 func Test_listening() | 20 func Test_listening() |
19 new | 21 new |
20 call setline(1, ['one', 'two']) | 22 call setline(1, ['one', 'two']) |
21 let s:list = [] | 23 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)}) |
23 call setline(1, 'one one') | 25 call setline(1, 'one one') |
24 call listener_flush() | 26 call listener_flush() |
25 call assert_equal([{'lnum': 1, 'end': 2, 'col': 1, 'added': 0}], s:list) | 27 call assert_equal([{'lnum': 1, 'end': 2, 'col': 1, 'added': 0}], s:list) |
26 | 28 |
27 " Undo is also a change | 29 " Undo is also a change |
63 call append(2, 'two two') | 65 call append(2, 'two two') |
64 call setline(1, 'something') | 66 call setline(1, 'something') |
65 call bufnr()->listener_flush() | 67 call bufnr()->listener_flush() |
66 call assert_equal([{'lnum': 3, 'end': 3, 'col': 1, 'added': 1}, | 68 call assert_equal([{'lnum': 3, 'end': 3, 'col': 1, 'added': 1}, |
67 \ {'lnum': 1, 'end': 2, 'col': 1, 'added': 0}], s:list) | 69 \ {'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) | |
68 | 73 |
69 " an insert just above a previous change that was the last one does not get | 74 " an insert just above a previous change that was the last one does not get |
70 " merged | 75 " merged |
71 call setline(1, ['one one', 'two']) | 76 call setline(1, ['one one', 'two']) |
72 call listener_flush() | 77 call listener_flush() |