Merge remote-tracking branch 'upstream/master'

This commit is contained in:
ckelsel 2017-08-10 08:31:50 +08:00
commit 9a5d309b57
7 changed files with 57 additions and 19 deletions

View File

@ -3162,8 +3162,8 @@ nobackup:
#ifdef UNIX
FileInfo file_info;
/* Don't delete the file when it's a hard or symbolic link. */
if ((!newfile && os_fileinfo_hardlinks(&file_info) > 1)
// Don't delete the file when it's a hard or symbolic link.
if ((!newfile && os_fileinfo_hardlinks(&file_info_old) > 1)
|| (os_fileinfo_link((char *)fname, &file_info)
&& !os_fileinfo_id_equal(&file_info, &file_info_old))) {
SET_ERRMSG(_("E166: Can't open linked file for writing"));
@ -4547,6 +4547,7 @@ int put_time(FILE *fd, time_t time_)
///
/// @return -1 for failure, 0 for success
int vim_rename(const char_u *from, const char_u *to)
FUNC_ATTR_NONNULL_ALL
{
int fd_in;
int fd_out;
@ -4822,6 +4823,7 @@ buf_check_timestamp (
buf_T *buf,
int focus /* called for GUI focus event */
)
FUNC_ATTR_NONNULL_ALL
{
int retval = 0;
char_u *path;

View File

@ -131,6 +131,7 @@ bool os_isdir(const char_u *name)
/// NODE_WRITABLE: writable device, socket, fifo, etc.
/// NODE_OTHER: non-writable things
int os_nodetype(const char *name)
FUNC_ATTR_NONNULL_ALL
{
#ifdef WIN32
// Edge case from Vim os_win32.c:

View File

@ -3,10 +3,12 @@
#
NVIM_PRG ?= ../../../build/bin/nvim
TMPDIR ?= Xtest-tmpdir
SCRIPTSOURCE := ../../../runtime
export SHELL := sh
export NVIM_PRG := $(NVIM_PRG)
export TMPDIR
SCRIPTS ?= \
test13.out \
@ -149,10 +151,12 @@ clean:
.*.swp \
.*.swo \
.gdbinit \
$(TMPDIR) \
del
test1.out: .gdbinit test1.in
-rm -rf $*.failed $(RM_ON_RUN) $(RM_ON_START) wrongtermsize
mkdir -p $(TMPDIR)
$(RUN_VIM) $*.in
@/bin/sh -c "if test -e wrongtermsize; then \
echo; \
@ -170,6 +174,7 @@ test1.out: .gdbinit test1.in
%.out: %.in .gdbinit
-rm -rf $*.failed test.ok $(RM_ON_RUN)
mkdir -p $(TMPDIR)
cp $*.ok test.ok
# Sleep a moment to avoid that the xterm title is messed up.
# 200 msec is sufficient, but only modern sleep supports a fraction of
@ -212,4 +217,5 @@ newtests: newtestssilent
newtestssilent: $(NEW_TESTS)
%.res: %.vim .gdbinit
mkdir -p $(TMPDIR)
$(RUN_VIMTEST) -u NONE -S runtest.vim $*.vim

View File

@ -2,7 +2,7 @@
func Test_complete_tab()
call writefile(['testfile'], 'Xtestfile')
call feedkeys(":e Xtest\t\r", "tx")
call feedkeys(":e Xtestf\t\r", "tx")
call assert_equal('testfile', getline(1))
call delete('Xtestfile')
endfunc
@ -17,7 +17,7 @@ func Test_complete_wildmenu()
call writefile(['testfile1'], 'Xtestfile1')
call writefile(['testfile2'], 'Xtestfile2')
set wildmenu
call feedkeys(":e Xtest\t\t\r", "tx")
call feedkeys(":e Xtestf\t\t\r", "tx")
call assert_equal('testfile2', getline(1))
call delete('Xtestfile1')

View File

@ -237,3 +237,31 @@ func Test_insert_expr()
close!
endfunc
func Test_undofile_earlier()
throw 'skipped: Nvim does not support test_settime()'
let t0 = localtime() - 43200
call test_settime(t0)
new Xfile
call feedkeys("ione\<Esc>", 'xt')
set ul=100
call test_settime(t0 + 1)
call feedkeys("otwo\<Esc>", 'xt')
set ul=100
call test_settime(t0 + 2)
call feedkeys("othree\<Esc>", 'xt')
set ul=100
w
wundo Xundofile
bwipe!
" restore normal timestamps.
call test_settime(0)
new Xfile
rundo Xundofile
earlier 1d
call assert_equal('', getline(1))
bwipe!
call delete('Xfile')
call delete('Xundofile')
endfunc

View File

@ -1838,11 +1838,9 @@ void undo_time(long step, int sec, int file, int absolute)
}
closest = -1;
} else {
/* When doing computations with time_t subtract starttime, because
* time_t converted to a long may result in a wrong number. */
if (dosec)
target = (long)(curbuf->b_u_time_cur - starttime) + step;
else if (dofile) {
if (dosec) {
target = (long)(curbuf->b_u_time_cur) + step;
} else if (dofile) {
if (step < 0) {
/* Going back to a previous write. If there were changes after
* the last write, count that as moving one file-write, so
@ -1880,14 +1878,16 @@ void undo_time(long step, int sec, int file, int absolute)
target = 0;
closest = -1;
} else {
if (dosec)
closest = (long)(time(NULL) - starttime + 1);
else if (dofile)
if (dosec) {
closest = (long)(os_time() + 1);
} else if (dofile) {
closest = curbuf->b_u_save_nr_last + 2;
else
} else {
closest = curbuf->b_u_seq_last + 2;
if (target >= closest)
}
if (target >= closest) {
target = closest - 1;
}
}
}
closest_start = closest;
@ -1916,12 +1916,13 @@ void undo_time(long step, int sec, int file, int absolute)
while (uhp != NULL) {
uhp->uh_walk = mark;
if (dosec)
val = (long)(uhp->uh_time - starttime);
else if (dofile)
if (dosec) {
val = (long)(uhp->uh_time);
} else if (dofile) {
val = uhp->uh_save_nr;
else
} else {
val = uhp->uh_seq;
}
if (round == 1 && !(dofile && val == 0)) {
/* Remember the header that is closest to the target.

View File

@ -803,7 +803,7 @@ static const int included_patches[] = {
// 152 NA
// 151,
150,
// 149,
149,
// 148,
147,
146,