Mercurial > vim
comparison src/testdir/test_listener.vim @ 17364:31f31e938961 v8.1.1681
patch 8.1.1681: insert stray "{" when listener gets buffer line
commit https://github.com/vim/vim/commit/0fb286e82d28730fcb3293894dd4df2e069eaf9a
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jul 13 20:14:45 2019 +0200
patch 8.1.1681: insert stray "{" when listener gets buffer line
Problem: Insert stray "{" when listener gets buffer line. (Paul Jolly)
Solution: Flush the cached line after invoking listeners. (closes https://github.com/vim/vim/issues/4455)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 13 Jul 2019 20:15:04 +0200 |
parents | ebe9aab81898 |
children | 2e53305f2239 |
comparison
equal
deleted
inserted
replaced
17363:b2a3efe4bc76 | 17364:31f31e938961 |
---|---|
240 | 240 |
241 call listener_remove(id) | 241 call listener_remove(id) |
242 delfunc MyListener | 242 delfunc MyListener |
243 bwipe! | 243 bwipe! |
244 endfunc | 244 endfunc |
245 | |
246 " This verifies the fix for issue #4455 | |
247 func Test_listener_caches_buffer_line() | |
248 new | |
249 inoremap <silent> <CR> <CR><Esc>O | |
250 | |
251 function EchoChanges(bufnr, start, end, added, changes) | |
252 for l:change in a:changes | |
253 let text = getbufline(a:bufnr, l:change.lnum, l:change.end-1+l:change.added) | |
254 endfor | |
255 endfunction | |
256 let lid = listener_add("EchoChanges") | |
257 set autoindent | |
258 set cindent | |
259 | |
260 call setline(1, ["{", "\tif true {}", "}"]) | |
261 exe "normal /{}\nl" | |
262 call feedkeys("i\r\e", 'xt') | |
263 call assert_equal(["{", "\tif true {", "", "\t}", "}"], getline(1, 5)) | |
264 | |
265 bwipe! | |
266 delfunc EchoChanges | |
267 call listener_remove(lid) | |
268 iunmap <CR> | |
269 set nocindent | |
270 endfunc |