Mercurial > vim
comparison src/testdir/test_listener.vim @ 17916:2e53305f2239 v8.1.1954
patch 8.1.1954: more functions can be used as a method
Commit: https://github.com/vim/vim/commit/02b31110d31e995326080807716e79e38fe501df
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Aug 31 22:16:38 2019 +0200
patch 8.1.1954: more functions can be used as a method
Problem: More functions can be used as a method.
Solution: Allow more functions to be used as a method.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 31 Aug 2019 22:30:03 +0200 |
parents | 31f31e938961 |
children | d19caa851682 |
comparison
equal
deleted
inserted
replaced
17915:50ad0353c88a | 17916:2e53305f2239 |
---|---|
57 call assert_equal([], s:list2) | 57 call assert_equal([], s:list2) |
58 | 58 |
59 " a change above a previous change without a line number change is reported | 59 " a change above a previous change without a line number change is reported |
60 " together | 60 " together |
61 call setline(1, ['one one', 'two']) | 61 call setline(1, ['one one', 'two']) |
62 call listener_flush() | 62 call listener_flush(bufnr()) |
63 call append(2, 'two two') | 63 call append(2, 'two two') |
64 call setline(1, 'something') | 64 call setline(1, 'something') |
65 call listener_flush() | 65 call bufnr()->listener_flush() |
66 call assert_equal([{'lnum': 3, 'end': 3, 'col': 1, 'added': 1}, | 66 call assert_equal([{'lnum': 3, 'end': 3, 'col': 1, 'added': 1}, |
67 \ {'lnum': 1, 'end': 2, 'col': 1, 'added': 0}], s:list) | 67 \ {'lnum': 1, 'end': 2, 'col': 1, 'added': 0}], s:list) |
68 | 68 |
69 " an insert just above a previous change that was the last one does not get | 69 " an insert just above a previous change that was the last one does not get |
70 " merged | 70 " merged |
132 let s:list3 = [] | 132 let s:list3 = [] |
133 call setline(1, 'asdfasdf') | 133 call setline(1, 'asdfasdf') |
134 redraw | 134 redraw |
135 call assert_equal([{'lnum': 1, 'end': 2, 'col': 1, 'added': 0}], s:list3) | 135 call assert_equal([{'lnum': 1, 'end': 2, 'col': 1, 'added': 0}], s:list3) |
136 | 136 |
137 call listener_remove(id) | 137 eval id->listener_remove() |
138 bwipe! | 138 bwipe! |
139 endfunc | 139 endfunc |
140 | 140 |
141 func s:StoreListArgs(buf, start, end, added, list) | 141 func s:StoreListArgs(buf, start, end, added, list) |
142 let s:buf = a:buf | 142 let s:buf = a:buf |
212 func Test_listening_other_buf() | 212 func Test_listening_other_buf() |
213 new | 213 new |
214 call setline(1, ['one', 'two']) | 214 call setline(1, ['one', 'two']) |
215 let bufnr = bufnr('') | 215 let bufnr = bufnr('') |
216 normal ww | 216 normal ww |
217 let id = listener_add(function('s:StoreBufList'), bufnr) | 217 let id = bufnr->listener_add(function('s:StoreBufList')) |
218 let s:list = [] | 218 let s:list = [] |
219 call setbufline(bufnr, 1, 'hello') | 219 call setbufline(bufnr, 1, 'hello') |
220 redraw | 220 redraw |
221 call assert_equal(bufnr, s:bufnr) | 221 call assert_equal(bufnr, s:bufnr) |
222 call assert_equal([{'lnum': 1, 'end': 2, 'col': 1, 'added': 0}], s:list) | 222 call assert_equal([{'lnum': 1, 'end': 2, 'col': 1, 'added': 0}], s:list) |