Mercurial > vim
diff 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 |
line wrap: on
line diff
--- a/src/testdir/test_listener.vim +++ b/src/testdir/test_listener.vim @@ -387,5 +387,36 @@ func Test_remove_listener_in_callback() unlet g:listener_called endfunc +func Test_no_change_for_empty_undo() + new + let text = ['some word here', 'second line'] + call setline(1, text) + let g:entries = [] + func Listener(bufnr, start, end, added, changes) + for change in a:changes + call add(g:entries, [change.lnum, change.end, change.added]) + endfor + endfunc + let s:ID = listener_add('Listener') + let @a = "one line\ntwo line\nthree line" + set undolevels& " start new undo block + call feedkeys('fwviw"ap', 'xt') + call listener_flush(bufnr()) + " first change deletes "word", second change inserts the register + call assert_equal([[1, 2, 0], [1, 2, 2]], g:entries) + let g:entries = [] + + set undolevels& " start new undo block + undo + call listener_flush(bufnr()) + call assert_equal([[1, 4, -2]], g:entries) + call assert_equal(text, getline(1, 2)) + + call listener_remove(s:ID) + bwipe! + unlet g:entries + delfunc Listener +endfunc + " vim: shiftwidth=2 sts=2 expandtab