changeset 17002:1f418d27e11f v8.1.1501

patch 8.1.1501: new behavior of b:changedtick not tested commit https://github.com/vim/vim/commit/260addf7955f3695d3daef9dcf840952af9fd851 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jun 8 20:48:36 2019 +0200 patch 8.1.1501: new behavior of b:changedtick not tested Problem: New behavior of b:changedtick not tested. Solution: Add a few test cases. (Daniel Hahler)
author Bram Moolenaar <Bram@vim.org>
date Sat, 08 Jun 2019 21:00:06 +0200
parents 1bf238956770
children 0363f6e9eac3
files src/testdir/test_changedtick.vim src/version.c
diffstat 2 files changed, 40 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_changedtick.vim
+++ b/src/testdir/test_changedtick.vim
@@ -55,3 +55,41 @@ func Test_changedtick_fixed()
   call assert_fails('unlet d["changedtick"]', 'E46:')
 
 endfunc
+
+func Test_changedtick_not_incremented_with_write()
+  new
+  let fname = "XChangeTick"
+  exe 'w ' .. fname
+
+  " :write when the buffer is not changed does not increment changedtick
+  let expected = b:changedtick
+  w
+  call assert_equal(expected, b:changedtick)
+
+  " :write when the buffer IS changed DOES increment changedtick
+  let expected = b:changedtick + 1
+  setlocal modified
+  w
+  call assert_equal(expected, b:changedtick)
+
+  " Two ticks: change + write
+  let expected = b:changedtick + 2
+  call setline(1, 'hello')
+  w
+  call assert_equal(expected, b:changedtick)
+
+  " Two ticks: start insert + write
+  let expected = b:changedtick + 2
+  normal! o
+  w
+  call assert_equal(expected, b:changedtick)
+
+  " Three ticks: start insert + change + write
+  let expected = b:changedtick + 3
+  normal! ochanged
+  w
+  call assert_equal(expected, b:changedtick)
+
+  bwipe
+  call delete(fname)
+endfunc
--- a/src/version.c
+++ b/src/version.c
@@ -768,6 +768,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1501,
+/**/
     1500,
 /**/
     1499,