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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0161
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.0161
Problem: Buffer not updated with 'autoread' set if file was deleted.
(Michael Naumann)
Solution: Don't set the timestamp to zero. (closes #3165)
Files: src/fileio.c, src/testdir/test_stat.vim
*** ../vim-8.1.0160/src/fileio.c 2018-06-22 21:30:27.351186530 +0200
--- src/fileio.c 2018-07-07 17:31:23.592491109 +0200
***************
*** 6923,6933 ****
{
retval = 1;
! /* set b_mtime to stop further warnings (e.g., when executing
! * FileChangedShell autocmd) */
if (stat_res < 0)
{
! buf->b_mtime = 0;
buf->b_orig_size = 0;
buf->b_orig_mode = 0;
}
--- 6923,6935 ----
{
retval = 1;
! // set b_mtime to stop further warnings (e.g., when executing
! // FileChangedShell autocmd)
if (stat_res < 0)
{
! // When 'autoread' is set we'll check the file again to see if it
! // re-appears.
! buf->b_mtime = buf->b_p_ar;
buf->b_orig_size = 0;
buf->b_orig_mode = 0;
}
*** ../vim-8.1.0160/src/testdir/test_stat.vim 2017-08-17 17:34:06.000000000 +0200
--- src/testdir/test_stat.vim 2018-07-07 18:27:11.809270986 +0200
***************
*** 46,51 ****
--- 46,60 ----
call assert_equal('rwx', getfperm(dname)[0:2])
endfunc
+ func SleepForTimestamp()
+ " FAT has a granularity of 2 seconds, otherwise it's usually 1 second
+ if has('win32')
+ sleep 2
+ else
+ sleep 1
+ endif
+ endfunc
+
func Test_checktime()
let fname = 'Xtest.tmp'
***************
*** 53,64 ****
call writefile(fl, fname)
set autoread
exec 'e' fname
! " FAT has a granularity of 2 seconds, otherwise it's usually 1 second
! if has('win32')
! sleep 2
! else
! sleep 1
! endif
let fl = readfile(fname)
let fl[0] .= ' - checktime'
call writefile(fl, fname)
--- 62,68 ----
call writefile(fl, fname)
set autoread
exec 'e' fname
! call SleepForTimestamp()
let fl = readfile(fname)
let fl[0] .= ' - checktime'
call writefile(fl, fname)
***************
*** 68,73 ****
--- 72,117 ----
call delete(fname)
endfunc
+ func Test_autoread_file_deleted()
+ new Xautoread
+ set autoread
+ call setline(1, 'original')
+ w!
+
+ call SleepForTimestamp()
+ if has('win32')
+ silent !echo changed > Xautoread
+ else
+ silent !echo 'changed' > Xautoread
+ endif
+ checktime
+ call assert_equal('changed', trim(getline(1)))
+
+ call SleepForTimestamp()
+ messages clear
+ if has('win32')
+ silent !del Xautoread
+ else
+ silent !rm Xautoread
+ endif
+ checktime
+ call assert_match('E211:', execute('messages'))
+ call assert_equal('changed', trim(getline(1)))
+
+ call SleepForTimestamp()
+ if has('win32')
+ silent !echo recreated > Xautoread
+ else
+ silent !echo 'recreated' > Xautoread
+ endif
+ checktime
+ call assert_equal('recreated', trim(getline(1)))
+
+ call delete('Xautoread')
+ bwipe!
+ endfunc
+
+
func Test_nonexistent_file()
let fname = 'Xtest.tmp'
*** ../vim-8.1.0160/src/version.c 2018-07-07 17:21:49.120140280 +0200
--- src/version.c 2018-07-07 17:33:03.899873420 +0200
***************
*** 791,792 ****
--- 791,794 ----
{ /* Add new patch number below this line */
+ /**/
+ 161,
/**/
--
hundred-and-one symptoms of being an internet addict:
197. Your desk collapses under the weight of your computer peripherals.
/// 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 ///
|