Patch 8.2.4379
Problem: An empty change is reported to a listener.
Solution: Do not report an empty change. (closes #9768) Remove unused
return value.
Files: src/undo.c, src/change.c, src/testdir/test_listener.vim
*** ../vim-8.2.4378/src/undo.c 2022-01-28 15:28:00.212927659 +0000
--- src/undo.c 2022-02-14 14:47:56.606189400 +0000
***************
*** 2828,2835 ****
if (curbuf->b_op_end.lnum > top + oldsize)
curbuf->b_op_end.lnum += newsize - oldsize;
}
!
! changed_lines(top + 1, 0, bot, newsize - oldsize);
// set '[ and '] mark
if (top + 1 < curbuf->b_op_start.lnum)
--- 2828,2835 ----
if (curbuf->b_op_end.lnum > top + oldsize)
curbuf->b_op_end.lnum += newsize - oldsize;
}
! if (oldsize > 0 || newsize > 0)
! changed_lines(top + 1, 0, bot, newsize - oldsize);
// set '[ and '] mark
if (top + 1 < curbuf->b_op_start.lnum)
*** ../vim-8.2.4378/src/change.c 2022-02-03 13:05:28.809273683 +0000
--- src/change.c 2022-02-14 14:47:33.150226923 +0000
***************
*** 155,163 ****
/*
* Check if the change at "lnum" is above or overlaps with an existing
* change. If above then flush changes and invoke listeners.
- * Returns TRUE if the change was merged.
*/
! static int
check_recorded_changes(
buf_T *buf,
linenr_T lnum,
--- 155,162 ----
/*
* Check if the change at "lnum" is above or overlaps with an existing
* change. If above then flush changes and invoke listeners.
*/
! static void
check_recorded_changes(
buf_T *buf,
linenr_T lnum,
***************
*** 185,191 ****
}
}
}
- return FALSE;
}
/*
--- 184,189 ----
***************
*** 206,213 ****
// If the new change is going to change the line numbers in already listed
// changes, then flush.
! if (check_recorded_changes(curbuf, lnum, lnume, xtra))
! return;
if (curbuf->b_recorded_changes == NULL)
{
--- 204,210 ----
// If the new change is going to change the line numbers in already listed
// changes, then flush.
! check_recorded_changes(curbuf, lnum, lnume, xtra);
if (curbuf->b_recorded_changes == NULL)
{
*** ../vim-8.2.4378/src/testdir/test_listener.vim 2021-09-11
14:06:40.484475113 +0100
--- src/testdir/test_listener.vim 2022-02-14 14:48:37.330124139 +0000
***************
*** 387,391 ****
--- 387,422 ----
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
*** ../vim-8.2.4378/src/version.c 2022-02-14 12:44:05.755468627 +0000
--- src/version.c 2022-02-14 14:08:47.197721951 +0000
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 4379,
/**/
--
Latest survey shows that 3 out of 4 people make up 75% of the
world's population.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220214145159.3AB1C1C0DFF%40moolenaar.net.