diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/testdir/test_undo.vim | 28 | ||||
-rw-r--r-- | src/undo.c | 8 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 33 insertions, 5 deletions
diff --git a/src/testdir/test_undo.vim b/src/testdir/test_undo.vim index fb1cdc836..f2ac6a8ea 100644 --- a/src/testdir/test_undo.vim +++ b/src/testdir/test_undo.vim @@ -235,3 +235,31 @@ func Test_insert_expr() close! endfunc + +func Test_undofile_earlier() + " Issue #1254 + " create undofile with timestamps older than Vim startup time. + 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 diff --git a/src/undo.c b/src/undo.c index 57c3c2021..607f35fdd 100644 --- a/src/undo.c +++ b/src/undo.c @@ -2298,10 +2298,8 @@ undo_time( } 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; + target = (long)(curbuf->b_u_time_cur) + step; else if (dofile) { if (step < 0) @@ -2350,7 +2348,7 @@ undo_time( else { if (dosec) - closest = (long)(vim_time() - starttime + 1); + closest = (long)(vim_time() + 1); else if (dofile) closest = curbuf->b_u_save_nr_last + 2; else @@ -2388,7 +2386,7 @@ undo_time( { uhp->uh_walk = mark; if (dosec) - val = (long)(uhp->uh_time - starttime); + val = (long)(uhp->uh_time); else if (dofile) val = uhp->uh_save_nr; else diff --git a/src/version.c b/src/version.c index b49f01f7f..7b47461ca 100644 --- a/src/version.c +++ b/src/version.c @@ -765,6 +765,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 149, +/**/ 148, /**/ 147, |