summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0813
blob: df6c6c20c2ddd94fa628ec86641066856e95ae0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0813
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.0813
Problem:    FileChangedShell not sufficiently tested.
Solution:   Add a more comprehensive test case.
Files:	    src/testdir/test_autocmd.vim


*** ../vim-8.1.0812/src/testdir/test_autocmd.vim	2019-01-09 23:00:57.997176121 +0100
--- src/testdir/test_autocmd.vim	2019-01-24 19:35:28.881281300 +0100
***************
*** 1385,1387 ****
--- 1385,1477 ----
    call delete('Xchanged.txt')
    bwipe!
  endfunc
+ 
+ func Test_FileChangedShell_reload()
+   if !has('unix')
+     return
+   endif
+   augroup testreload
+     au FileChangedShell Xchanged let g:reason = v:fcs_reason | let v:fcs_choice = 'reload'
+   augroup END
+   new Xchanged
+   call setline(1, 'reload this')
+   write
+   " Need to wait until the timestamp would change by at least a second.
+   sleep 2
+   silent !echo 'extra line' >>Xchanged
+   checktime
+   call assert_equal('changed', g:reason)
+   call assert_equal(2, line('$'))
+   call assert_equal('extra line', getline(2))
+ 
+   " Only triggers once
+   let g:reason = ''
+   checktime
+   call assert_equal('', g:reason)
+ 
+   " When deleted buffer is not reloaded
+   silent !rm Xchanged
+   let g:reason = ''
+   checktime
+   call assert_equal('deleted', g:reason)
+   call assert_equal(2, line('$'))
+   call assert_equal('extra line', getline(2))
+ 
+   " When recreated buffer is reloaded
+   call setline(1, 'buffer is changed')
+   silent !echo 'new line' >>Xchanged
+   let g:reason = ''
+   checktime
+   call assert_equal('conflict', g:reason)
+   call assert_equal(1, line('$'))
+   call assert_equal('new line', getline(1))
+ 
+   " Only mode changed
+   silent !chmod +x Xchanged
+   let g:reason = ''
+   checktime
+   call assert_equal('mode', g:reason)
+   call assert_equal(1, line('$'))
+   call assert_equal('new line', getline(1))
+ 
+   " Only time changed
+   sleep 2
+   silent !touch Xchanged
+   let g:reason = ''
+   checktime
+   call assert_equal('time', g:reason)
+   call assert_equal(1, line('$'))
+   call assert_equal('new line', getline(1))
+ 
+   if has('persistent_undo')
+     " With an undo file the reload can be undone and a change before the
+     " reload.
+     set undofile
+     call setline(2, 'before write')
+     write
+     call setline(2, 'after write')
+     sleep 2
+     silent !echo 'different line' >>Xchanged
+     let g:reason = ''
+     checktime
+     call assert_equal('conflict', g:reason)
+     call assert_equal(3, line('$'))
+     call assert_equal('before write', getline(2))
+     call assert_equal('different line', getline(3))
+     " undo the reload
+     undo
+     call assert_equal(2, line('$'))
+     call assert_equal('after write', getline(2))
+     " undo the change before reload
+     undo
+     call assert_equal(2, line('$'))
+     call assert_equal('before write', getline(2))
+ 
+     set noundofile
+   endif
+ 
+ 
+   au! testreload
+   bwipe!
+   call delete('Xchanged')
+ endfunc
*** ../vim-8.1.0812/src/version.c	2019-01-24 18:20:14.436543394 +0100
--- src/version.c	2019-01-24 19:36:50.824706620 +0100
***************
*** 789,790 ****
--- 789,792 ----
  {   /* Add new patch number below this line */
+ /**/
+     813,
  /**/

-- 
You were lucky to have a LAKE! There were a hundred and sixty of
us living in a small shoebox in the middle of the road.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///