Mercurial > vim
comparison src/testdir/test_listener.vim @ 27706:17cd22b7151b v8.2.4379
patch 8.2.4379: an empty change is reported to a listener
Commit: https://github.com/vim/vim/commit/55737c2a31ed450dd7bf2a9c587adfbb32b755bb
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Feb 14 14:51:22 2022 +0000
patch 8.2.4379: an empty change is reported to a listener
Problem: An empty change is reported to a listener.
Solution: Do not report an empty change. (closes https://github.com/vim/vim/issues/9768) Remove unused
return value.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 14 Feb 2022 16:00:03 +0100 |
parents | 5ef74c37a9a1 |
children | 711ae604980a |
comparison
equal
deleted
inserted
replaced
27705:327558d9a331 | 27706:17cd22b7151b |
---|---|
385 bwipe! | 385 bwipe! |
386 delfunc Listener | 386 delfunc Listener |
387 unlet g:listener_called | 387 unlet g:listener_called |
388 endfunc | 388 endfunc |
389 | 389 |
390 func Test_no_change_for_empty_undo() | |
391 new | |
392 let text = ['some word here', 'second line'] | |
393 call setline(1, text) | |
394 let g:entries = [] | |
395 func Listener(bufnr, start, end, added, changes) | |
396 for change in a:changes | |
397 call add(g:entries, [change.lnum, change.end, change.added]) | |
398 endfor | |
399 endfunc | |
400 let s:ID = listener_add('Listener') | |
401 let @a = "one line\ntwo line\nthree line" | |
402 set undolevels& " start new undo block | |
403 call feedkeys('fwviw"ap', 'xt') | |
404 call listener_flush(bufnr()) | |
405 " first change deletes "word", second change inserts the register | |
406 call assert_equal([[1, 2, 0], [1, 2, 2]], g:entries) | |
407 let g:entries = [] | |
408 | |
409 set undolevels& " start new undo block | |
410 undo | |
411 call listener_flush(bufnr()) | |
412 call assert_equal([[1, 4, -2]], g:entries) | |
413 call assert_equal(text, getline(1, 2)) | |
414 | |
415 call listener_remove(s:ID) | |
416 bwipe! | |
417 unlet g:entries | |
418 delfunc Listener | |
419 endfunc | |
420 | |
390 | 421 |
391 " vim: shiftwidth=2 sts=2 expandtab | 422 " vim: shiftwidth=2 sts=2 expandtab |